필터 지우기
필터 지우기

How do you stop a MATLAB GUI from clearing axes between plot commands?

조회 수: 4 (최근 30일)
I have a GUI that I'm using to place initial locations for a 6DOF sim. I want the points to use different markers (a red circle and a gray triangle), but every time I use two plot3 commands, the GUI plots the first then clears and plots the second. I'm using the hold on ... hold off command. Is there a way to fix this or use one command?
Here's what happens after the 'Place' button is pressed:
Code for reference:
hold on
plot3(app.UIAxes,missile_init_x,missile_init_y,...
missile_init_alt,'ko','MarkerSize',15,'MarkerFaceColor',...
'r') % <--------- Some form of clear/reset happens here
plot3(app.UIAxes,target_init_x,target_init_y,0,'kv',...
'MarkerSize',20,'MarkerFaceColor',0.5*[1 1 1])
hold off

채택된 답변

Image Analyst
Image Analyst 2022년 5월 25일
Is it possible your missile and target coordinates are exactly overlapping? Or are in line with each other from that point of view so that you see only the closest one? Do you see both if you rotate the axes? This seems to work fine:
missile_init_x = -1000;
missile_init_y = -1000;
missile_init_alt = 2000;
target_init_x = 1000;
target_init_y = 1000;
hold on
plot3(missile_init_x,missile_init_y,...
missile_init_alt,'ko','MarkerSize',15,'MarkerFaceColor',...
'r') % <--------- Some form of clear/reset happens here
plot3(target_init_x,target_init_y,0,'kv',...
'MarkerSize',20,'MarkerFaceColor',0.5*[1 1 1])
grid on;
view(500, 500)
hold off
  댓글 수: 1
James Floyd
James Floyd 2022년 5월 25일
That works in regular MATLAB, but in the GUI, it doesn't which is the most confusing part of all of this.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Gavin
Gavin 2022년 10월 20일
편집: Gavin 2022년 10월 20일
Encountered the same issue myself, ended up fixing it by setting
app.UIAxes.NextPlot = 'add'
in my startupFcn
and then juggling the intended clearing behavior with
cla(app.UIAxes)
To figure this out, I ran my app from the command window like
app = AppCommand(appParam1, appParam2,...)
and then going into the variable explorer and poking around the properties of app.UIAxes, which seem to be fairly intuitively named. Hope this solves your issue!

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by