- 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
조회 수: 38 (최근 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
2025년 12월 19일 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:
댓글 수: 6
Walter Roberson
대략 4시간 전
Yes. Use getframe to record the axes or the figure, imwrite and then imread it from the file and store the result in an array. Or just getframe since that stores the results in an array directly.
Caution: if you are thinking of animating the various files, then be careful, since getframe() and exportgraphics by default are not precisely consistent on the size of the captured image, so it is common to need to imresize to get exact consistency.
참고 항목
카테고리
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!

