i have a field in which i plot something. as soon as i click on a button the code is executed.
plot(app.UIAxes3,track,bottomLine,'r',track,topLine,'g');
hold(app.UIAxes3,'on')
plot(app.UIAxes3,track,-bottomLine,'r',track,-topLine,'g');
now i would like to plot a vertical line over it, which i move from left to right depending on a variable change. Without always replotting the image. Is that possible?
the image should only be replotted when I press the button again
Thanks

 採用された回答

Adam Danz
Adam Danz 2020 年 7 月 21 日
編集済み: Adam Danz 2020 年 7 月 21 日

1 投票

You can plot the line using xline() and then merely update it's Value property to move it. The line's handle must be stored as an app property.
1) Define a property verticalLineHandle (you can rename it) as an app property. See instructions.
2) Plot the line somewhere in your code (a callback function or at startup) and store the handle.
app.verticalLineHandle = xline(app.UIAxes3, 0); % this plots the vert line at x=0
3) In your button callback function, all you need to do is change the value of the line to move it.
app.verticalLineHandle.Value = 1; % Now the line is at x=1

4 件のコメント

prrrrr
prrrrr 2020 年 7 月 21 日
編集済み: prrrrr 2020 年 7 月 21 日
but then the old line does not disappear.
as soon as i change the value via an external button, my plot and the "old" line remains. And the new one with the value appears in addition.
prrrrr
prrrrr 2020 年 7 月 21 日
i create it with
app.verticalLineHandle = xline(app.UIAxes3, 0);
than i plot my other plots
and after this in another callback i change it with
app.verticalLineHandle.Value = app.newvalue;
prrrrr
prrrrr 2020 年 7 月 21 日
and it works
Adam Danz
Adam Danz 2020 年 7 月 21 日
Yes, that's the correct way to implement it.
A line will be produced every time you call the xline() function. So, only call that once. Then update the xline value as needed.
To delete the line,
delete(app.verticalLineHandle)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

リリース

R2020a

質問済み:

2020 年 7 月 21 日

コメント済み:

2020 年 7 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by