|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2003-8-21 05:44:19
|
显示全部楼层
46).在Matlab中有goto语句吗?
:#FangQ(Qianqian.Fang@dartmouth.edu), 2002/7/23. BigGreen/en_Matlab#
matlab中没有提供goto,因为结构化程序设计不推荐使用goto,但在matlab
中,goto的功能可以部分用结构化的异常处理机制来实现,比如从多重循环
中跳出,具体代码为:
try
for i=1:10
for j=1:10
for k=1:10
do_something;
if(jump_condition)
errorid=-2;
error('I want to get out!');
end
end
end
end
catch
fprintf(1,'catch error:%d',errorid);
end
不过这只是跳出循环向下的,它返不回去。欢迎大家来研究。哈哈 |
|