MATLAB Onramp
Vectors and Matrices
Array Creation Functions
创建随机数矩阵
x = rand(2)
x =
0.8147 0.1270
0.9058 0.9134
x = rand(2,3)
x =
0.6324 0.2785 0.9575
0.0975 0.5469 0.9649
获得已知矩阵的大小
size(x)
Indexing into and Modifying Arrays
Indexing into Arrays (Indexing into Arrays)
%You can extract values from an array using *row, column indexing*.
y = A(5,7)
%This syntax extracts the value in the 5th row and 7th column of `A`
%and assigns the result to the variable `y`.
If you only use one index with a matrix, it will traverse down each column in order.
按列分配
%When used as an index, the colon operator (`:`) specifies all the elements in that dimension. The syntax
% 行
x = A(2,:)
% 列
y = A(:,2)
%creates a row vector containing all of the elements from the second row of `A`.
x = A(1:3,:)%三行
volumes=data(:,3:4)%3 4列