Filter löschen
Filter löschen

How can I update a plot on GUI ?

4 Ansichten (letzte 30 Tage)
Synchro_mdn
Synchro_mdn am 26 Aug. 2018
Kommentiert: Image Analyst am 26 Aug. 2018
Hi everyone.
I was trying to modify the plot of my GUI. The problem is : I plot a sine wave plot (T, Y), where T=to:1/(20*f):tf; And all value are given by an user through the GUI and executed by a Run button. Then, the user should be able to use a slider to modify the T (at Real Time) axes by
>xinput=set(handle.slider,'value')
>T=to:1/(xinput*f):tf;
Then plot it again on the GUI.
Thanks.
  5 Kommentare
Synchro_mdn
Synchro_mdn am 26 Aug. 2018
Yes, I did. I hadn't tried it yet. The dorwnow go at the end of the code, right?
Image Analyst
Image Analyst am 26 Aug. 2018
It can go whenever you think you want to repaint/refresh the screen. Otherwise it will refresh only when it thinks it's not too busy. Usually when you're in a fast loop you want to put the drawnow inside the loop or else it might not repaint the screen until all the iterations have finished. If it works, can you Accept the answer below?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 26 Aug. 2018
It should work. If it's not, then add this line:
drawnow;
after your plotting code. But it sounds like you want the graph to update both when you click the Run button and when you move the slider. In that case, have each control's callback function call a function called GraphCurve() or something like that. Then GraphCurve would look something like:
function handles = GraphCurve(handles)
sliderValue = handles.slider1.Value % Get value from slider control.
Y = .... some function of T and sliderValue.
plot(T, Y, 'b*-', 'LineWidth', 2);
grid on;
xlabel('T', 'FontSize', 20);
ylabel('Y', 'FontSize', 20);
title('Y vs. T', 'FontSize', 20);
drawnow;
Again, have both your Run button's callback function and your slider control's callback function call this function.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by