MATLAB Answers

Create complex legend with two string including variables values.

7 views (last 30 days)
Davide Bassignana
Davide Bassignana on 19 Nov 2017
I'm trying to add a legend to a plot where multiple variable are plotted in two y axes. I want to highlight two values on this plot (concerning only one axis) and add a legend about only this points.
here is the code:
str_lgd1 =['Real eigenvalue for U = ',...
num2str(U_stop(1)), ' m/s' char(10) 'Re(p) = ', ...
str_lgd2 = ['Real eigenvalue for U = ',...
num2str(U_stop(2)), ' m/s' char(10) 'Re(p) = ', ...
lgd=legend([p5 p6],str_lgd1,str_lgd2);
p5 and p6 are the objects I want to add the legend. str_lgd1 and str_lgd2 are the string I want to be displayed. The error is:
Operands to the || and && operators must be convertible to logical scalar values.
Error in legend (line 189)
all(isgraphics(args{1})) % legend(children,strings,...)
Error in Es4 (line 244)
lgd=legend([p5 p6],{str_lgd1,str_lgd2});

Answers (0)

Community Treasure Hunt

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

Start Hunting!