フィルターのクリア

How can I add legend to graph with each loop for ezplot?

3 ビュー (過去 30 日間)
Akshay Kumar
Akshay Kumar 2016 年 9 月 16 日
コメント済み: Walter Roberson 2016 年 9 月 18 日
Hello,
I am plotting blending function of bezier curve, in which number of blending curve depends on the number of control points taken.
Now, my problem is I want to add legend for each graph(ezplot) which is plotted by running loop?
Please! help me.
Code is:
%%Plotting of blending curve
for i=1:length(b)
ezplot(b(i),[min(u),max(u)])
hold on
end

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 9 月 16 日
%%Plotting of blending curve
for i=1:length(b)
h(i) = ezplot(b(i),[min(u),max(u)]);
leg_entries{i} = sprintf('b = %g', b(i));
hold on
end
legend(h, leg_entries)
  2 件のコメント
Akshay Kumar
Akshay Kumar 2016 年 9 月 18 日
Thank you sir,
but when I applied the same code, it is not accepting as [b] is symbolic matrix.
if true
% code
%%Plotting of blending curve
for i=1:length(b)
h(i) = ezplot(b(i),[min(u),max(u)]);
leg_entries{i} = sprintf('b = %g', b(i));
hold on
end
legend(h, leg_entries)
((Error using sprintf
Function is not defined for 'sym' inputs.))
end
But I got the idea from you to store the legend information in cell array. and that worked with some modification.
ezplot(b(i),[min(u),max(u)]);
legendinfo{i}=['B',int2str(i),',',int2str(length(b))];
thank you sir,
Akshay Kumar
Walter Roberson
Walter Roberson 2016 年 9 月 18 日
You could also use
leg_entries{i} = sprintf('b = %s', char(b(i)));

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

カテゴリ

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