Matlab 逻辑与流程控制
常见的 书上可以找怎么用
if ...else...end
for...end
while...end
switch...case...end
本章就是书上的内容可以上网自己查,就介绍怎么用
%for...end结构
for 循环变量 = 初值 :步长 :终值
执行语句 1
.
.
.
执行语句 n
end
while...end结构
while 条件表达式
执行语句 1
.
.
.
执行语句 n
end
%if...end结构
if 条件表达式
.
.
.
语句体
.
.
.
end
%if..else...end结构
if 表达式
语句体1
else
语句体2
end
%switch...case...end结构
switch 表达式(数值或字符串)
case 数值或字符串1
语句体1;
case 数值或字符串2
语句体2;
.
.
.
otherwise
语句体n;
end