一般为 if 条件 内容 end 或 if 条件 内容 else if 内容 end 或者 if (expression1) {commands1} else if (expression2) {commands2} else if (expression3) {commands3} else if …… ………………………………… else {commands} end end end …… end
蘇瑾熙
2021-01-17 01:32:17
找出第一行是3,第二行是7,把这一行的第1个数换成10. clear all
clc
a=[2 3 4 5 6;
7 7 7 8 8]';
for i=1:length(a)
if(a(i,2)==7)
if (a(i,1)==3)
b(i,1)=10;
else
b(i,1)=a(i,1);
end
b(i,2)=7;
end
end 复制代码
抵住引诱
2022-05-14 16:33:29
clear all clc
a=[2 3 4 5 6; 7 7 7 8 8]';
for i=1:length(a) if(a(i,2)==7) if (a(i,1)==3) b(i,1)=10; else b(i,1)=a(i,1); end b(i,2)=7; end end