[英]Unable to use the output of inputdlg in the get function
I want to use the input value from the dialog box and save it as sp_name. 我想使用对话框中的输入值并将其另存为sp_name。 Saving it directly to sp_name is giving me an error.
将其直接保存到sp_name会给我一个错误。 Kindly help me out.
请帮我。 It seems that as soon as the inputdlg is closed, ans variable is destroyed.
似乎一旦inputdlg关闭,ans变量就会被销毁。 what should I do?
我该怎么办?
Code: 码:
ans = inputdlg('Save as:','New user');
sp_name=get(handles.ans,'String');
Error: 错误:
Reference to non-existent field 'ans'
The output from inputdlg is a cell array. inputdlg的输出是一个单元格数组。 Hence you need to use:
因此,您需要使用:
sp_name = ans{1};
In your code above, Matlab does not recognize the structure handles and it throws the error. 在上面的代码中,Matlab无法识别结构句柄,并引发错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.