【发布时间】:2014-06-03 13:04:40
【问题描述】:
我有一个 Input 函数,它有两个选项供用户输入,GUI 和来自 Command 在 Matlab 中。
GUI 是通过回调和Command 输入的,变量简单。我想为它构建一个函数,但无法创建为 GUI 不需要任何输出函数变量,而 Command 需要一个变量,在我的情况下如何创建函数?
我的代码:
function varargout = Input()
choice = questdlg(sprintf([ '1. GUI \n\n' '2. Command \n\n' ]), 'Input Choice?', 'GUI', 'Command', 'Command');
switch choice
case 'GUI'
GUI();
case 'Command'
[p] = Command;
if nargout > 0
varargout{1} = p;
end
end
end
【问题讨论】:
-
为什么不使用它的自定义输出,例如 varargout{1} = [];或可变参数{1} = 0;
GUI();的正下方表示选择了 GUI 选项? -
@Divakar 我不能很好地理解你的观点,请写下答案,以便我了解你的观点。
-
类似这样的东西 -
case 'GUI', GUI();varargout{1} = [];然后case 'Command' .... -
@Divakar 当我调用像
p=Input这样的函数时,它只适用于case 'Command'但GUI()给出p的错误,这就是问题所在。 -
我试过了,效果很好。
标签: matlab function user-interface output