matlab中报错Improper assignment with rectangular empty matrix.M=[1 2 3;4 5 6;7 8 9];for i=1:1:size(M,2)n(i)=find(M(:,i)==1);m(i)=length(n(i));end我就是想找出每一列中1的个数,

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/18 21:44:22
matlab中报错Improper assignment with rectangular empty matrix.M=[1 2 3;4 5 6;7 8 9];for i=1:1:size(M,2)n(i)=find(M(:,i)==1);m(i)=length(n(i));end我就是想找出每一列中1的个数,
xݑJ@_$`jf] Nہf:LRYhі΍tT|f+_Ifi;Wp̝uq'/'qy32!"Ң!1쑸 m:MNW}wǂ2uڄ*lPˁm9Ěoum|6w-Yi+nkat"h.>W1\$tp+Z"yÙԹw|J1F*`@*,r=p+1TV"c*SQ"+SUB͗ K,߮D%(3#P/ߡ/

matlab中报错Improper assignment with rectangular empty matrix.M=[1 2 3;4 5 6;7 8 9];for i=1:1:size(M,2)n(i)=find(M(:,i)==1);m(i)=length(n(i));end我就是想找出每一列中1的个数,
matlab中报错Improper assignment with rectangular empty matrix.
M=[1 2 3;4 5 6;7 8 9];
for i=1:1:size(M,2)
n(i)=find(M(:,i)==1);
m(i)=length(n(i));
end
我就是想找出每一列中1的个数,

matlab中报错Improper assignment with rectangular empty matrix.M=[1 2 3;4 5 6;7 8 9];for i=1:1:size(M,2)n(i)=find(M(:,i)==1);m(i)=length(n(i));end我就是想找出每一列中1的个数,

最简单的写法:

M=[1 2 3;4 5 6;7 8 9];
sum(M==1,1)

结果:[1 0 0]