while循环在条件为true时重复执行语句。
matlab中while循环语法是-
while <expression> <statements> end
创建脚本文件并键入以下代码-
a=10; % while loop execution while( a < 20 ) fprintf('value of a: %d\n', a); a=a + 1; end
运行文件时,它将显示以下结果-
value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 15 value of a: 16 value of a: 17 value of a: 18 value of a: 19
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)