Matrix 在MATLAB中将列_向量更改为矩阵
我有一个列向量需要转换成矩阵。矩阵的大小已指定,可以更改。请建议矢量化解决方案Matrix 在MATLAB中将列_向量更改为矩阵,matrix,Matrix,我有一个列向量需要转换成矩阵。矩阵的大小已指定,可以更改。请建议矢量化解决方案 rows = 3 ; cols = 4 ; %matrix elements for this case = 12 colvector = [ 2;4;5;8;10;14;16;18;20;21;28;30] ; desired_mat = [ ... 2 4 5 8 10 14 16 18
rows = 3 ; cols = 4 ; %matrix elements for this case = 12
colvector = [ 2;4;5;8;10;14;16;18;20;21;28;30] ;
desired_mat = [ ...
2 4 5 8
10 14 16 18
20 21 28 30 ] ;
谢谢 该函数执行以下操作:
>> colvector = [ 2;4;5;8;10;14;16;18;20;21;28;30] ;
>> A = reshape(colvector, 3, 4)
A =
2 8 16 21
4 10 18 28
5 14 20 30