vector of line chart objects returned by plot - problem with modifying markers,...

1 回表示 (過去 30 日間)
SA-W
SA-W 2021 年 7 月 22 日
回答済み: darova 2021 年 7 月 25 日
Dear all,
Here is a snippet of my code:
plot_array = zeros(5,1);
x=0:0.1:1000;
y=x.^3
for p=1:1:5
plot_array(p) = loglog(x,y, /*arbitrary markers and legend which I would like to modify after the loop);
hold on;
end
legend_array(2,1).Marker = '+';
The last line produces the error message: "Unable to perform assignment because dot indexing is not supported for variables of this type".
I tried to reproduce the example from the loglog documention. The only difference to my code is that (i) I have an array, -> legend_array(2,1), and (ii) I plot only one pair of vectors, that is why I omitted something like (legend_array(2,1))(1).Marker = '+' .
Thanks for helping me!
  1 件のコメント
SA-W
SA-W 2021 年 7 月 22 日
I resolved my issue by initializing plot_array as
plot_array = matlab.graphics.chart.primitive.Line.empty(5,0);
Is there may a more elegant way to store line objects?

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

採用された回答

darova
darova 2021 年 7 月 25 日
Try this
x = 0:10;
y = sin(x);
h(1) = plot(x,y,'r');
h(2) = line(x,y+.5);
set(h(2),'marker','.')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFormatting and Annotation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by