MatLab基本语法
1.输入:A=input('请输入A的值:\n')
2.输出:disp('A的值=')
disp(A)
3.暂停:pause(2) 暂停2秒
4.if语句 matlab中的if语句后要加end elseif
例:
if A>0
disp('A>0');
elseif A==0
disp('A=0');
esle
disp('A<0')
end
5.switch语句
switch fix(A/10)
case 0
disp('A<10');
case {1,2,3,4}
disp('10<=A<50');
case {5,6,7,8,9}
disp('50<=A<100');
otherwise
disp('A>=100');
6.try语句
try
语句
catch
语句
end
7.for循环
for k=1:100
循环操作
end

浙公网安备 33010602011771号