%% 用来划分多个section,每个section可单独运行
~= Not equal to
prod(1:n) n! prod乘积
close all 清除所有图像
ctrl+c 用来终止程序
if else
判断condition是否是true
if condition1
statement1
elseif condition2
statement2
else
statement3
end
switch
表达式是一个数值,根据数值找对应
switch expression
case value1
statement1
case value2
statement2
otherwise
statement
end
while
while condition
statement
end
条件成立执行语句,举例注意n的值变化:
for
for variable=start:increment:end
commands
end
但是,当列表为1:2:10时,偶数位空缺补0
练习:将矩阵A中的元素copy至矩阵B,复制时将负值改变为正值
break
与while循环一起使用,不满足条件则跳出循环
用户自定义function
呼叫function >> edit(which('freebody.m'))
注意为什么用.*而不用* : 若输入为数组时,计算不会出错(分别计算)