Creating an active graph that allows variables to be updated in real time.

27 vues (au cours des 30 derniers jours)
John Carroll
John Carroll le 26 Avr 2022
Commenté : John Carroll le 26 Avr 2022
Hello
I am attempting to create a graph that I can update in real time. Currently I plot (see below) F vs D0. D0 pulls a single row from the variable TunabilityD3C and extracts a single point that I define. Here it is the 20th point in the row. It is this point I'd like to actively update. Right now I just manually change the point then rerun the script to regenerate the graph. I'd like to create a slider bar that will change the value of Freq within the range I set then have the graph update in real time as I do this.
Any help is apprieated.
F=[6 10 12 14 16];
Freq = 20;
D0=[TunabilityD3C(1,Freq),TunabilityD3C(2,Freq),TunabilityD3C(3,Freq),TunabilityD3C(4,Freq),TunabilityD3C(5,Freq)];
plot(F, D0,'rs-','LineWidth',2)

Réponses (1)

Rik
Rik le 26 Avr 2022
Modifié(e) : Rik le 26 Avr 2022
Plot once, and use the callback function of a slider to set the XData and YData properties of that object.
Don't forget to round the value property of the slider to an integer.
I suspect the indexing will be fast enough to just run that code every time. If not, you could pre-calculate the y values for all possible values of Freq and store that in an array.
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread.
  1 commentaire
John Carroll
John Carroll le 26 Avr 2022
Thanks. I'll have to read more about the call abck function as it is new to me.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by