try_catch.m
来自「matlab源代码,适用于开发研究,带来很好的学习效果.」· M 代码 · 共 15 行
M
15 行
%初始化数组
a=[1 -3 2 5];
try
% 显示某个元素
index=input('Enter subscript of element to display: ');
disp(['a(' int2str(index) ') = ' num2str(a(index))] );
catch
%如果发现出现错误
disp(['Illegal subscript: ' int2str(index)] );
% 显示错误类型
A=lasterr;
disp(['The type of error: ' A ]);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?