## for循环 ``` for i = 初始:步长:结束 end ``` 打印一个矩阵元素 ``` A = [1, 2, 3; 4, 5, 6; 7, 8, 9]; for i = 1:1:3 for j = 1:1:3 A(i,j) end end ``` ## while循环 ``` while 条件 end ``` ## if ``` if 表达式 elseif 表达式 end ``` 表达式可以加括号也可以不加 ## switch ``` switch 表达式(数字或者字符串) case xxx case xxx otherwise end ``` Loading... ## for循环 ``` for i = 初始:步长:结束 end ``` 打印一个矩阵元素 ``` A = [1, 2, 3; 4, 5, 6; 7, 8, 9]; for i = 1:1:3 for j = 1:1:3 A(i,j) end end ``` ## while循环 ``` while 条件 end ``` ## if ``` if 表达式 elseif 表达式 end ``` 表达式可以加括号也可以不加 ## switch ``` switch 表达式(数字或者字符串) case xxx case xxx otherwise end ``` Last modification:December 18, 2022 © Allow specification reprint Like 如果觉得我的文章对你有用,请随意赞赏