Azzera filtri
Azzera filtri

Storing User Input in a Matrix

1 visualizzazione (ultimi 30 giorni)
Emma Sellers
Emma Sellers il 30 Set 2019
Risposto: Gregory McFadden il 30 Set 2019
I am attempting to write code that takes user input in with the dialog boxes. But i need the user input to then be stored in a matrix as it is gathered.. Is there a way to do this? I have tried by places the dialog boxes in a while loop..
function[Source, resistors] = simplecircuit(voltage, current)
for cnt = 1:2
Source(cnt) = inputdlg({'Voltage Value','Node','Node'},...
'Source Placement',[1 10; 1 5; 1 5]);
end
for i = 1:2
resistors = inputdlg({'Resistor Value','Node','Node'},...
'Source Placement',[1 50; 1 12; 1 7]);
end
end

Risposte (1)

Gregory McFadden
Gregory McFadden il 30 Set 2019
Have you tried just making a GUI for this? It is particularly easy to just have a table and use the cell edit callback to perform an action whenever a cell is edited. If the table length is highly variable, either in the cell edit callback or with a different function, extra rows can be added only when necessary.
Either in Guide or appdesigner, it is quite easy to handle these types of input tasks, then just have a button to command execution of the rest of your code once the table is populated.

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by