元胞数组
元胞数组
A=cell(1,6)
A{2}=eye(3),eye(3)为3*3对角线为1的单位矩阵,A{2}表示将eye(3)放入第二个cell
B=A{2} 将B中第二个cell给A
结构体
books=struct('name',{{'123','456'}},'price',[10 20])
books.name
books.name(1)
books.name{1}
基本程序结构
1.for 循环变量=初值:步长:终值
.
.
执行语句n
end
步长为1可以省略
2. while 条件表达式
执行语句1
.
.
执行语句n
end
- if 条件表达式
执行语句1
.
.
执行语句n
end
- if 条件表达式
执行语句1
.
.
else 执行语句n
end
- switch 表达式
case 数值或字符串1
语句体1
case数值或字符串2
语句体2
otherwise
语句体n
end