作业帮 > 综合 > 作业

matlab中报错Improper assignment with rectangular empty matrix.

来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/06/16 21:51:32
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];
sum(M==1,1)结果:[1 0 0]