Storing User Input in a Matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Gregory McFadden
2019년 9월 30일
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!