i need help with inuptdlg
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Abdelmalek Benaimeur
el 25 de Mzo. de 2019
Editada: Abdelmalek Benaimeur
el 26 de Mzo. de 2019
hello folks
i'm using appdesigner to build an app, i added a push button called save to workspace which allow to the user to save the results to workspace
this is the code i used
prompt = {'Choose the figure name','Choose the Tree name',...
'Choose the Clusters name','Choose the Roots name'};
answer = inputdlg(prompt);
assignin('base',answer{1},app.Figure);
assignin('base',answer{2},app.Tree);
assignin('base',answer{3},app.Clusters);
assignin('base',answer{4},app.Roots);
when i click the pushbutton i obtain this
but the problem is that the user must give a name for all the 4 outputs (results) ,
is there a way to make the user choose the number of the outputs he wants to save
0 comentarios
Respuesta aceptada
Arvind Sathyanarayanan
el 25 de Mzo. de 2019
Ah! The syntax for inputdlg() is:
answer = inputdlg(prompt,dlgtitle,dims,definput)
The error was because when defining the default input, dlgtitle and dims must also be defined. The correct code is:
prompt = {'Choose the figure name','Choose the Tree name',...
'Choose the Clusters name','Choose the Roots name'};
dlgtitle = 'Input';
dims = 1;
definput={'fig1','tree1','cname','rname'};
answer = inputdlg(prompt,dlgtitle,dims,definput);
0 comentarios
Más respuestas (4)
Arvind Sathyanarayanan
el 25 de Mzo. de 2019
You could specify default values for the 4 inputs. Example:
prompt = {'Choose the figure name','Choose the Tree name',...
'Choose the Clusters name','Choose the Roots name'};
definput={'fig1','tree1','cname','rname'}
inputdlg(prompt,definput)
0 comentarios
Abdelmalek Benaimeur
el 25 de Mzo. de 2019
1 comentario
Arvind Sathyanarayanan
el 26 de Mzo. de 2019
You could check to see if answer is empty before you send it to the workspace. Example:
prompt = {'Choose the figure name','Choose the Tree name',...
'Choose the Clusters name','Choose the Roots name'};
answer = inputdlg(prompt);
for i=1:4
if ~isempty(answer{i})
evalin('base', 'answer{i}');
end
end
Abdelmalek Benaimeur
el 26 de Mzo. de 2019
Editada: Abdelmalek Benaimeur
el 26 de Mzo. de 2019
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!