- Use hold on before the while loop. That will cause the various compassplot() to accumulate onto the same axes. As you are not providing x values distinct from y values to the various compassplots(), this would result in all of the compassplot() sharing the same axes and getting tangled with each other. That is potentially a problem (but might be what you want.)
- Use figure or uifigure inside the while loop but before the compassplot() call. This will result in completely different figures being generated for the various compassplot()
- Use subplot() before each compassplot() call (including before the one before the loop). subplot() creates distinct graphics axes for the content to go into.
- Use tiledlayout() before the first compassplot() call, and then nexttile() before each compassplot() call. nexttile() creates distinct graphics axes for the content to go into, but does so in a nicer more modern way than subplot() does
How do I Create an array of plots. The results disapear into "handle to deleted PolarCompassPlot" See code
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clearvars -except Radius_list Six_plots
Circle_num = 4
nlist = 1;
%Six_plots = F_six_plots(Circle_num, Radius_list);
Six_plots;
sz = size(Six_plots,2);
Plot_num(1:sz) = compassplot(ones)
jplot = 1;
while jplot < sz
Plot_num(nlist) = compassplot(Six_plots(1:nlist));
nlist = nlist+1;
jplot = jplot+1
end
X = Plot_num
Stepping thru the while works. Plot_num(nlist) is fine
X is all "handle to deleted PolarCompassPlot"
0 Kommentare
Antworten (1)
Walter Roberson
am 19 Dez. 2025 um 7:59
You are calling compassplot() in a loop.
By default, each call to compassplot() removes all existing graphics on the axes -- so each call to compassplot() is deleting the previous compassplot()
You have four options:
4 Kommentare
Paul
vor 32 Minuten
Can you describe in words what you are trying to accomplish? Is the end goal separate and distinct plots built from subsets of the same data set? Is the end goal a single, animated plot? Something else?
It would be nice if some example SixPlots data is provided (can save to a .mat file and upload that using the Paperclip icon in the Insert menu)
Here is some sample code that implements a few of the ideas that @Walter Roberson suggested. Maybe one will resonate.
Create some example data
theta = 0:60:300;
rho = 1:6;
SixPlots = rho.*(cosd(theta)+1j*sind(theta));
One figure, one polar axis, with six arrows
figure
P1 = compassplot(SixPlots);
One figure, six polar axes, each with one arrow
figure;
t = tiledlayout(3,3);
for ii = 1:6
nexttile
P2(ii) = compassplot(SixPlots(ii));
end
set([P2.Parent],'RLim',[0,6]);
One figure, one axes, six arrows, each arrow added in a loop by updating the properties of the plot, for an animated effect (not seen here on Answers). Note that for this to work we have to make the first plot with the first data point, not an empty input as suggested above.
figure
P3 = compassplot(SixPlots(1));
for ii = 2:6
set(P3,'Rdata',abs(SixPlots(1:ii)),'ThetaData',angle(SixPlots(1:ii)));
drawnow
end
As expected, P1 and P3 are scalar handles to PolarCompassPlot and P2 is a 1x6 vector of handles to PolarCompassPlot(s)
P1,P2,P3
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


