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.