MATLAB Answers

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

조회 수: 57(최근 30일)
John Hunt
John Hunt 23 Jan 2019
댓글: John Hunt 25 Jan 2019
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
John Hunt
John Hunt 23 Jan 2019
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 24 Jan 2019
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
John Hunt
John Hunt 25 Jan 2019
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by