How do i manage the number of input dialog box according to the user's choice?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
DIJESH
el 23 de Mayo de 2014
Comentada: DIJESH
el 23 de Mayo de 2014
Suppose the program is to find average of the numbers given by the user. The first step would be to create a dialog box to ask the user the number of numbers to be input. Second step would be to prompt dialog boxes where the user will enter the numbers. Now, here the number of dialog boxes prompted must be equal to the number input by the user in the 1st step. How do I manage the number of prompts?
0 comentarios
Respuesta aceptada
Mischa Kim
el 23 de Mayo de 2014
DIJESH, you could use something like
prompt = 'Enter data: ';
title = 'Data input';
dlg_ans = inputdlg(prompt,title,[1 100]);
data = str2num(dlg_ans{:});
where the user would enter numbers (separated by empty spaces) and thereby avoiding a second input dialog.
4 comentarios
Mischa Kim
el 23 de Mayo de 2014
Editada: Mischa Kim
el 23 de Mayo de 2014
It depends what you need to do. With the above approach you can access the individual values as components of the array (e.g. data(1)). In general I would advise against using n different variable names and rather go with arrays.
Más respuestas (0)
Ver también
Categorías
Más información sobre Structures 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!