MATLAB: How can i keep asking them the same inputdlg based on how many they want to input

countinputdlg

count='How many values do you want?';
vcount=inputdlg(count);
eqprompt='Enter Values';
value(vcount)=inputdlg(eqprompt);
eqprompt='Enter Values';
value(vcount)=inputdlg(eqprompt);
How to repeat the "Enter Value' dialog box until the count is equal to the number of times it repeat?

Best Answer

  • count='How many values do you want?';
    vcount=inputdlg(count);
    vcount = str2double(vcount{1});
    eqprompt='Enter Values';
    value = [];
    for i = 1 : vcount
    answer =inputdlg(eqprompt);
    try value(1, i)= str2double(answer{1}); %this is for empty input. In case you changed your mind with the number of inputs
    catch
    break;
    end
    end