一:Script writing
1. 新建脚本
2.测试代码
for i=1:10
x=linspace(0,10,101);
plot(x,sin(x+i));
print(gcf,'-deps',strcat('plot',num2str(i),'.ps'));
end
3.保存.m文件并运行(F5)
4.注释:%
5.section:%%
6.调试
二:Structured programming
1.操作符
常规:>、<、>=、<=、==
操作符 | 含义 |
---|---|
~= | 不等于 |
&& | 与 |
| | | 或 |
# python :!= and or
2.与python不同,matlab不严格要求缩进
3.条件语句
# python :if elif else
a=3;
if rem(a,2)==0
disp('a is even')
else
disp('a is odd')
end
input_num=1