Set() hPlot question

10 ビュー (過去 30 日間)
m j
m j 2019 年 4 月 8 日
回答済み: Walter Roberson 2019 年 4 月 8 日
Hello, I have a 3 X 63950 double worth of data, and have been trying to plot it using set(hPlot1,'Xdata',...,'Ydata',...); but cant figure out what the problem is.
NOTE: Data is a (3 X127900) double I want to plot a certain number of values.
set(hPlot1, 'Xdata',1:63950,'Ydata',Data(:,1:2:end));
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 8 日
Is hPlot1 a scalar handle or a vector of handles?
m j
m j 2019 年 4 月 8 日
Vector, but its been a long time since I used matlab so, forgive me if its something very simple. But I setup my plots,sublots like so....
hAxes1 = subplot(2,3,1);
hPlot1 = plot(hAxes1,NaN,NaN);

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 8 日
You need to use the obscure syntax for set in which the first parameter is a vector of handles and the second input is a cell array of character vectors indicating the properties to change and the third parameter is a cell array of new values carefully arranged.
When you call set with a vector of handles and the next parameter is a character vector, then that is a request to set that property to the same value for all of the handles. set does *not* have a syntax like
set([h1, h2], 'YData', {h1ydata, h2ydata}) %invalid
set([h1, h2], 'YData', [h1ydata(:), h2ydata(:)]) %would set both handles to same value
The only syntax for set() that permits different values for different handles on the same call is the cell array of character vectors one that is a bit confusing to set up.
Most of the time it is easier and clearer to just use a loop or arrayfun or cellfun. I only use the cell array of character vectors properties syntax if efficiency is especially important... Or sometimes with a scalar handle if I used get with a cell array of character vectors to query multiple properties.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by