How do i redraw a graph when a button is pressed in GUI?

Hi Team,
I have a GUI which plots 7 graphs. when i re-enter the button with required changes, i want graph to be re-written instead of getting another 7 set of graphs. Please help me in solving this.

回答 (2 件)

Jan
Jan 2014 年 1 月 21 日

0 投票

You can store the handles of the corresponding AXES or LINE objects and either replace the exiting lines or update their XData and YData.
When you post more details, a more precise answer is possible.

1 件のコメント

Radhika
Radhika 2014 年 1 月 21 日
Lets say for an example,
plot([Vmax_tar, Vmax_tar], [0, 1], 'b-','linewidth',2,'markersize',5);
if i want to plot it again with different value of Vmax_tar, the graph must be overwritten for new value intead of creating a new graph

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

Amit
Amit 2014 年 1 月 21 日

0 投票

If you're using GUI, the axes where you're plotting must have a handle. you can find it in your .fig file. In general that would be axes1, axes2 something like this.
Before plotting, bring axes focus on that plot. In other words something like this:
axes(handles.axes1); % Lets says your plot spaces is named axes1 (change it accordingly)
% handles is the structure for GUI
plot([Vmax_tar, Vmax_tar], [0, 1], 'b-','linewidth',2,'markersize',5);
This will update the plot.

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2014 年 1 月 21 日

回答済み:

2014 年 1 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by