Changing default values for inputdlg()
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael
am 10 Mär. 2014
Bearbeitet: Michael
am 13 Mär. 2014
I'm trying to work out a way such that if a user inputs some values into a dialogue box then exits it, those previous values are saved and then reused as the default values when the user open it again.
I've tried using the command in a loop with variables for the default answers which I then change i.e with m = answer(1). But when I try using variables instead on actual numbers like {'1', '2', '3'}, I get an error saying 'Default Answer must be a cell array of strings.'
Does anyone know how this may be done?
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 10 Mär. 2014
Bearbeitet: Mischa Kim
am 10 Mär. 2014
Michael, does this do what you need?
defaultanswer = {'20','hsv'};
for ii = 1:2
prompt ={'Enter the matrix size for x^2:',...
'Enter the colormap name:'};
name = 'Input for Peaks function';
numlines = 1;
defaultanswer = inputdlg(prompt,name,numlines,defaultanswer);
end
I suspect that your variables are numeric, in which case you need to convert to string, using, e.g., the num2str command.
3 Kommentare
Mischa Kim
am 10 Mär. 2014
Bearbeitet: Mischa Kim
am 10 Mär. 2014
I just used the loop to open the dialog twice to show how to store answers from the dialog box for later use. Of course, you can also call inputdlg again and again in different parts of your code.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Performance and Memory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!