首先抱歉,如果问题没有明确说明,因为我不知道如何描述它。我的问题如下:
让k = menu('a','b','c');
如果k> 0
程序继续
否则
终止程序和disp('请选择一个选项') 菜单功能将再次弹出以供选择。
我该如何编程这种情况?感谢任何善意提出想法的人。
答案 0 :(得分:0)
要执行您所描述的操作,可以使用error()
if K <= 0
error("Please select option")
end
%The rest of your code here:
但是设置一个等待正确用户输入的while循环会更有意义:
while k <= 0
let k = menu('a', 'b', 'c') % I don't fully understand how you are setting k, but that bit goes here
if k <= 0
disp('please select an option');
end
end
% The rest of your code here