- 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
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
about 5 hours 前
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:
1 个评论
Walter Roberson
20 minutes 前
Plot_num(nlist) = compassplot(Six_plots(1:nlist));
nlist = nlist+1;
The action of that code would be to create multiple plots, each one starting from the beginning of the data, and adding one additional point each time (drawing from the beginning of the data each time), but saving each of the plot handles.
It seems unlikely that is what you want to do.
If you have reason to want to animate the drawing of the compassplot() then normally what you would do is first
cp = compassplot([]);
and then loop,
%do NOT make any more compassplot() calls inside the loop!
set(cp, 'theta', ThetaData(1:nlist), 'rho', SixPlots(1:nlist));
drawnow();
where ThetaData is a new variable that indicates the various theta that you want to draw the points at.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!