控制语句
for循环
>> v=zeros(10,1);
>> for i=1:10,
v(i) = 2^i;
end;
>> v
v =
2
4
8
16
32
64
128
256
512
1024
索引
>> indices = 1:10;
>> for i=indices,
disp(i);
end;
1
2
3
4
5
6
7
8
9
10
while循环及break,continue使用
>> i=1;
>> while true,
v(i) = 999;
i = i+1;
if i == 6,
break;
end; %结束的是 if 语句
end; %结束的是 while 语句
>> v
v &#