简体   繁体   中英

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. Saving it directly to sp_name is giving me an error. Kindly help me out. It seems that as soon as the inputdlg is closed, ans variable is destroyed. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM