How to switch between plotting on two different axis in one gui function

4 ビュー (過去 30 日間)
John Hunt
John Hunt 2019 年 1 月 23 日
コメント済み: John Hunt 2019 年 1 月 25 日
I have a data set that includes 25 sets of time, position x, y,z forces, and torque. I am using a GUI to access all of the data and plot a portion of any two of the columns on a single plot that updates with a slider bar. I have gotten that to work great, however I now want to be able to have a second plot that will plot data similar to the first and update in the same slide bar. I am having trouble switching from one plot to the other and the data updates on the most recent plot. How can I switch between these two?
  2 件のコメント
Oliver Woodford
Oliver Woodford 2019 年 1 月 23 日
Is this already ansewered here?: https://www.mathworks.com/matlabcentral/answers/714-how-can-i-change-the-current-axes-in-a-gui
John Hunt
John Hunt 2019 年 1 月 23 日
編集済み: John Hunt 2019 年 1 月 24 日
So I have tried this. But an error comes up that says "Invalid axes handle". I have some logic that determines which data is plotted and before each plot I have the line axes(handles.axes2);
for which plot I want to plot on, but if I try to plot to the same axes that was used last I get that error.
It will work once but then the second time it throws that error.
a simple pseudo code for this program is as follows
load data sets and put them in handles
dropdown menus for what data
% - radio buttton -
if button is 1
if certian drop down options are loaded
axes(handels.plot);
polarplot(data1(first section, data2)
hold on
polarplot(data1(2nd section, data2) (this is done to achive different colors)
hold on
Axes(handles.a_plot)
plot(data3, data4)
hold on
else
axes(handles.plot);
cla
axes(handels.a_plot);
cla
When I clear the button that is when it breaks and gives the error spoken above.

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

採用された回答

Kevin Chng
Kevin Chng 2019 年 1 月 24 日
Hi,
Put the name of your axes in the first argument of your function plot. Example :
plot(handles.axes1,[0 1],[0 1])
plot(handles.axes2,[0 3],[0 1])
  3 件のコメント
Kevin Chng
Kevin Chng 2019 年 1 月 25 日
I'm not sure with your application, have you closed any figure? The axes might be in the figure, then later closed by you.
Therefore, the axes is deleted.
John Hunt
John Hunt 2019 年 1 月 25 日
I have figured it out. The plot was made with cartesian so when I called for a polarplot the handles.axes1 was deleted to support the new one. So after plotting I assigned the handles.axes1 to the current gca and updated my handles. This is working great. Thanks

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by