MATLAB: Request user input and using that ans for the functions

matlab gui

How can I use the user's input and convert it to a numerical value to be used in my remaining codes?
prompt=('Enter a threshold value to convert the grayscale image to black and white: ');
dlg_title=('Threshold level value');
num_lines=1;
defaultans={'0.5'};
answer=inputdlg(prompt,dlg_title,num_lines,defaultans);

Best Answer

>> val = str2double(answer{1})
val =
3