Could anyone help me how to overcome the error in the following code:

5 ビュー (過去 30 日間)
jaah navi
jaah navi 2020 年 1 月 13 日
コメント済み: jaah navi 2020 年 1 月 13 日
code:
x = linspace(0,10);
y1 = sin(x);
y2 = sin(0.9*x);
y3 = sin(0.8*x);
y4 = sin(0.7*x);
y5 = sin(0.6*x);
y6 = sin(0.5*x);
plot(x,y1,'DisplayName','sin(x)')
hold on
plot(x,y2,'DisplayName','sin(0.9x)')
plot(x,y3,'DisplayName','sin(0.8x)')
plot(x,y4,'DisplayName','sin(0.7x)')
plot(x,y5,'DisplayName','sin(0.6x)')
plot(x,y6,'DisplayName','sin(0.5x)')
hold off
lgd = legend;
lgd.NumColumns = 2;
when i run the code it displays the graph but it has no legend in it.Instead it display the error stating No public field NumColumns exists for class matlab.graphics.illustration.Legend.
I ma using matlab 2015a version.Could anyone please help me on it.

回答 (2 件)

Robert U
Robert U 2020 年 1 月 13 日
Hi jaah navi,
To display the legend use
lgd = legend('show');
The property/method 'NumColumns' does not exist. What is the purpose of that command?
Kind regards,
Robert
  3 件のコメント
Robert U
Robert U 2020 年 1 月 13 日
"As of Matlab 2018a, legend() now supports columns, so function will no longer be maintained: https://www.mathworks.com/help/matlab/ref/legend.html#d117e809522".
Kind regards,
Robert
jaah navi
jaah navi 2020 年 1 月 13 日
Thanks for your suggestion.

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


Walter Roberson
Walter Roberson 2020 年 1 月 13 日
That feature did not exist in your MATLAB release.
... When are you going to upgrade? You keep running into these kinds of problems.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by