有些matlab程序里面总有这么句话if isempty(b) || length(size(vec))~=2 || min(size(vec))>1是什么意思?还有 A=zeros(n,n);for z=1:nfor s=1:nswitch scase 1if z==1A(z,s)=1;elseA(z,s)=sum(A(z-1,:));endotherwiseA(z,s)=sum(A(z,1:s))+1;endende
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/03 03:15:33
![有些matlab程序里面总有这么句话if isempty(b) || length(size(vec))~=2 || min(size(vec))>1是什么意思?还有 A=zeros(n,n);for z=1:nfor s=1:nswitch scase 1if z==1A(z,s)=1;elseA(z,s)=sum(A(z-1,:));endotherwiseA(z,s)=sum(A(z,1:s))+1;endende](/uploads/image/z/12507065-17-5.jpg?t=%E6%9C%89%E4%BA%9Bmatlab%E7%A8%8B%E5%BA%8F%E9%87%8C%E9%9D%A2%E6%80%BB%E6%9C%89%E8%BF%99%E4%B9%88%E5%8F%A5%E8%AF%9Dif+isempty%28b%29+%7C%7C+length%28size%28vec%29%29%7E%3D2+%7C%7C+min%28size%28vec%29%29%3E1%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%3F%E8%BF%98%E6%9C%89+A%3Dzeros%28n%2Cn%29%3Bfor+z%3D1%3Anfor+s%3D1%3Answitch+scase+1if+z%3D%3D1A%28z%2Cs%29%3D1%3BelseA%28z%2Cs%29%3Dsum%28A%28z-1%2C%3A%29%29%3BendotherwiseA%28z%2Cs%29%3Dsum%28A%28z%2C1%3As%29%29%2B1%3Bendende)
有些matlab程序里面总有这么句话if isempty(b) || length(size(vec))~=2 || min(size(vec))>1是什么意思?还有 A=zeros(n,n);for z=1:nfor s=1:nswitch scase 1if z==1A(z,s)=1;elseA(z,s)=sum(A(z-1,:));endotherwiseA(z,s)=sum(A(z,1:s))+1;endende
有些matlab程序里面总有这么句话if isempty(b) || length(size(vec))~=2 || min(size(vec))>1是什么意思?
还有 A=zeros(n,n);
for z=1:n
for s=1:n
switch s
case 1
if z==1
A(z,s)=1;
else
A(z,s)=sum(A(z-1,:));
end
otherwise
A(z,s)=sum(A(z,1:s))+1;
end
end
end
尤其那两个求和的公式实在不明白
能在详细说明一下那两个求和公式的意思吗?还是不大明白
有些matlab程序里面总有这么句话if isempty(b) || length(size(vec))~=2 || min(size(vec))>1是什么意思?还有 A=zeros(n,n);for z=1:nfor s=1:nswitch scase 1if z==1A(z,s)=1;elseA(z,s)=sum(A(z-1,:));endotherwiseA(z,s)=sum(A(z,1:s))+1;endende
if isempty(b) || length(size(vec))~=2 || min(size(vec))>1
表示:如果矩阵b是空的或矩阵vec的维数不等于2或vec的最小维数应该大于1中有一个为真则该命令行为真
A(z,s)=sum(A(z-1,:));表示求A矩阵z-1行的所有所有列的数的和放在A矩阵的z行s列的位置上
A(z,s)=sum(A(z,1:s))+1;表示求A矩阵z-1行1到s列所有数的和放在A矩阵的z行s列的位置上