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

28 ビュー (過去 30 日間)
John Carroll
John Carroll 2022 年 4 月 26 日
コメント済み: John Carroll 2022 年 4 月 26 日
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)

回答 (1 件)

Rik
Rik 2022 年 4 月 26 日
編集済み: Rik 2022 年 4 月 26 日
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 件のコメント
John Carroll
John Carroll 2022 年 4 月 26 日
Thanks. I'll have to read more about the call abck function as it is new to me.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by