早教吧 育儿知识 作业答案 考试题库 百科 知识分享

matlab [m,n] = size(X) X = rand(2,3,4);then下面两行怎么解释?[m1,m2,m3,m4] = size(X) returns m1 = 2,m2 = 3,m3 = 4,m4 = 1.[m,n] = size(X) returns m = 2,n = 12.

题目详情
matlab [m,n] = size(X)
X = rand(2,3,4);
then
下面两行怎么解释?
[m1,m2,m3,m4] = size(X) returns m1 = 2,m2 = 3,m3 = 4,m4 = 1.
[m,n] = size(X) returns m = 2,n = 12.
▼优质解答
答案和解析
X = rand(2,3,4); X是4维向量,每个分量是2*3的矩阵
[m1,m2,m3,m4] = size(X) returns m1 = 2,m2 = 3,m3 = 4,m4 = 1.
此时 4>ndims(X)=3,多余的放1
[m,n] = size(X) returns m = 2,n = 12.
此时 2< ndims(X)=3,n=3*4=m2*m3