In your code, NOF never changes inside the loop. Therefore, if the loop enters, it won't ever exit because the exit condition will never be true. Make sure you are calling str2double within the loop:
res=inputdlg('Enter number of floors:');
nof=str2double(res);
while isempty(res) || isnan(nof)
disp('error')
res=inputdlg('Enter number of floors:');
nof=str2double(res);
end
If you want to let the user use the command line:
opts.WindowStyle = 'normal';
res=inputdlg('Enter number of floors:', '', 1, {''}, opts);
nof=str2double(res);
while isempty(res) || isnan(nof)
disp('error')
res=inputdlg('Enter number of floors:', '', 1, {''}, opts);
nof=str2double(res);
end
Best Answer