How To Write Long Plot Handle

조회 수: 3 (최근 30일)
Matthew
Matthew 2017년 10월 11일
댓글: Matthew 2017년 10월 11일
My code has the plot handle shown below that is used with 'plot3.' Seventeen different data sets (i.e., n=17) are being plotted together. The problem is that I need to use this syntax for plots of other sizes (e.g., n=6, n=12, n=<fill in the blank>, etc.) and don't want to write it out individually each time. Can this syntax be generated on-the-fly somehow? In other words, is there some way to run a FOR loop that will write this out, appending it for each loop until n has been reached, and then issue plot3 with it?
h1=plot3(coll{1}(:,1),coll{1}(:,2),coll{1}(:,3),coll{2}(:,1),coll{2}(:,2),coll{2}(:,3),...
coll{3}(:,1),coll{3}(:,2),coll{3}(:,3),coll{4}(:,1),coll{4}(:,2),coll{4}(:,3),...
coll{5}(:,1),coll{5}(:,2),coll{5}(:,3),coll{6}(:,1),coll{6}(:,2),coll{6}(:,3),...
coll{7}(:,1),coll{7}(:,2),coll{7}(:,3),coll{8}(:,1),coll{8}(:,2),coll{8}(:,3),...
coll{9}(:,1),coll{9}(:,2),coll{9}(:,3),coll{10}(:,1),coll{10}(:,2),coll{10}(:,3),...
coll{11}(:,1),coll{11}(:,2),coll{11}(:,3),coll{12}(:,1),coll{12}(:,2),coll{12}(:,3),...
coll{13}(:,1),coll{13}(:,2),coll{13}(:,3),coll{14}(:,1),coll{14}(:,2),coll{14}(:,3),...
coll{15}(:,1),coll{15}(:,2),coll{15}(:,3),coll{16}(:,1),coll{16}(:,2),coll{16}(:,3),...
coll{17}(:,1),coll{17}(:,2),coll{17}(:,3));
Thanks in advance,
M Ridzon
  댓글 수: 2
Jan
Jan 2017년 10월 11일
The usage of the term "handle" is not clear here.
Matthew
Matthew 2017년 10월 11일
My apologies. The Help documentation often refers to the them as "handles" and that's where I gleaned it from. "Handle" here refers to "h1." It's merely a pointer (i.e., handle) for the plot. Later when setting other plot preferences, certain commands (e.g., 'set') references the handle to implement the commands. Hopefully that clears it up a bit.

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

채택된 답변

Jan
Jan 2017년 10월 11일
편집: Jan 2017년 10월 11일
What about:
axes('NextPlot', 'add'); % or : hold('oll')
h = gobject(1, n);
for k = 1:n
h(k) = plot3(coll{k}(:,1), coll{k}(:,2), coll{k}(:,3));
end
  댓글 수: 1
Matthew
Matthew 2017년 10월 11일
This works beautifully and is much cleaner. Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by