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

조회 수: 7 (최근 30일)
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 CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by