'Set' function applied on handle and vector of handle

3 ビュー (過去 30 日間)
Greg
Greg 2013 年 4 月 12 日
Hi everyone!
Here is a quick shot of a current optimization problem: Let's assume we have a vertical vector of handles. Each handle have been produced by executing the 'plot3' function, and each corresponding curve is defined by two points (twice {X Y Z}).
h(1) = plot3([44 55],[0 0],[0 0],'-r'); hold on,
h(2) = plot3([66 77],[0 0],[0 0],'-r');
h(3) = plot3([88 99],[0 0],[0 0],'-r');
h = [h(1); % vector of handle
h(2);
h(3)];
Thus:
get(h(1),'XData')
gives
ans = [44 55]
ie the two x values of the two points of this curve
Then:
set(h(1),'XData',[11 0])
get(h(1),'XData')
gives
ans = [11 0]
Whereas:
set(h,'XData',[[11 0];
[22 0];
[33 0]])
causes
Error using ==> set
Value must be a column or row vector
Here comes trouble, I would like to update all XData properties of each handle in a single command, without making a loop. Is there any solution to that?
Thanks you very much for any kind of help, I am scratching my head on that since days!
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 4 月 12 日
Try
set(h,'XData',{[11 0];
[22 0];
[33 0]})

サインインしてコメントする。

採用された回答

Greg
Greg 2013 年 4 月 12 日
Okay just found it!
A = [11 0;
22 0;
33 0];
set(h,{'XData'},num2cell(A,2))
And by the way thanks Walter, your tip to add {} is equivalent to num2cell. But then {} around 'XData' also have to be added.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by