How To Write Long Plot Handle

1 回表示 (過去 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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by