フィルターのクリア

How to assign a handle in set function for figures?

3 ビュー (過去 30 日間)
Kian
Kian 2014 年 10 月 27 日
コメント済み: Kian 2014 年 10 月 27 日
This does not work. It gives me error: Error using set Value must be a handle
I understand the problem, should make var in the last line to be a handle, but can't figure out how to fix it! and is it possible to assign different colors to each plot when m loops through.
var = ['p' num2str(m)];
eval([var '= plot(x,y);']);
set(var,'Marker','o')
Thanks is advance.
  2 件のコメント
Image Analyst
Image Analyst 2014 年 10 月 27 日
I don't have any idea what you're trying to do, but I'm sure that this is not the way to do it. It's wrong in more ways that one. Take a step back and give us the big picture, like you want to use different markers on different curves in your graph, or whatever...
Kian
Kian 2014 年 10 月 27 日
Basically what I'mm trying to do is plot several graphs into one figure, and assign each a different set of colors and markers. May be something like the following would better explain this considering x and y are updated in each loop (new datasets):
for m = 1:5
var = ['p' num2str(m)];
eval([var '= plot(x,y);']);
set(var,'Marker','o')
end
but I want to use different markers though each loop for each graph.
Hope this explains the issue better.

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

採用された回答

Chad Greene
Chad Greene 2014 年 10 月 27 日
Does this do what you're looking for?
x = linspace(0,2*pi,100);
markers = {'x','+','s','p','^'};
colors = colormap(jet(5));
LineWidths = 1:5;
hold on
for k = 1:5
h(k) = plot(x,randi(10)*sin(x*rand(1)),...
'marker',markers{1},...
'color',colors(k,:),...
'linewidth',LineWidths(k));
end
If you'd like to set values after plotting, h contains a handle for each plotted object.
  1 件のコメント
Kian
Kian 2014 年 10 月 27 日
Thank you Chad, this works.
Thank you again.

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

その他の回答 (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