for语句:
for i=1:n %i从1到n,默认为间隔为1
%(循环语句)
end
for i=1:0.5:n %设置间隔为0.5
%(循环语句)
end
if语句:
if (x>0.5)
y=2*x;
else
y=x+0.5;
%如果有多个选项
if(x>0.5)
y=2*x;
elseif(x<0.8) %elseif连在一起
y=x+0.5;
else
y=x+0.8;
end %注意end
原文:https://www.cnblogs.com/yz-lucky77/p/11180649.html