How to save values calculated in each iteration of a loop into uitable to display on GUI?

For example: y = 5*x;
for x=1:10
y(x) = 5*x;
end
When x = 1; y = 5; I want to display these values on uitbale; and then display forward for each iteration to the end of loop

 Risposta accettata

You can do this:
data = [x(:) y(:)];
set(handles.uitable,'Data',data); % Assuming handles.uitable is the handle to the uitable in the GUI
Hope this helps!

8 Commenti

Thank for your answer, CS
It seems to display all data into uitable, but in my case I use large number of variables and take a long time for each iteration. Therefore, I need to display the result after each iteration
Do you mean x and y are updated after each iteration? If yes, then do this in each iteration
data = [x y];
set(handles.uitable,'Data',data);
Hi CS I have tried the syntax above but there is a error:
wellCountNPV =
1.0e+04 *
0.0230 1.5314
0.0113 2.7044
0.0023 0.2649
0.0413 2.4199
0.0220 1.4241
0.0051 0.1754
0.0074 0.4027
0.0071 1.1382
0.0145 0.1349
0.0213 0.8991
Reference to a cleared variable handles.
Error in untitled>pushbutton1_Callback (line 138)
set(handles.uitable1,'Data',wellCounNPV);
Can you handle this problem?
There are files I have used. I try to use GUI in 'untitled.m'. Can you fix for me to update after each iteration ?
Hey where are the files? I am sorry I cannot find them.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by