MATLAB是特定于行还是特定于列? [英] Is MATLAB row specific or column specific?

查看:132
本文介绍了MATLAB是特定于行还是特定于列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MATLAB中,我们可以对矩阵的行和列进行操作. 特定于行或特定于列"的确切含义是什么.对于这个幼稚的问题,我感到抱歉. 谢谢!

In MATLAB, we can operate on both rows and columns of a matrix. What does it exactly mean by "row specific or column specific". I'm sorry for this naive question. Thanks!

推荐答案

重要的是要了解MATLAB将数据存储在

It is important to understand that MATLAB stores data in column-major order, so you know what happens when you apply the colon operator without any commas:

>> M = magic(3)
M =
     8     1     6
     3     5     7
     4     9     2
>> M(:)
ans =
     8
     3
     4
     1
     5
     9
     6
     7
     2

我倾向于认为"MATLAB先跌后跌".这使得reshapepermute数组变得容易,而无需加扰数据.为了掌握线性索引(例如M(4)).

I tend to think "MATLAB goes down, then across". This makes it easy to reshape and permute arrays without scrambling your data. It's also necessary in order to grasp linear indexing (e.g. M(4)).

例如,从某些生成数组的表达式中获取列向量内联的一种常见方法是:

For example, a common way to obtain a column vector inline from some expression that generates an array is:

reshape(<array expression>,[],1)

(:)一样,它可以将所有列彼此堆叠成单个列向量,以存储任何更高维度的所有数据. 但是,这种巧妙的语法技巧使您避免了多余的代码行.

As with (:) this stacks all the columns on top of each other into single column vector, for all data in any higher dimensions. But this nifty syntactic trick lets you avoid an extra line of code.

这篇关于MATLAB是特定于行还是特定于列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆