MATLAB Answers

Adding variables to legends

13 views (last 30 days)
Dan Lardner
Dan Lardner on 18 Sep 2021
Hi,
I wish to add a variable to a legend which I have discovered how to do, however I would like to have the initial element within the legend untouched and add the variable to the second parameter within the legend.
This piece of code displays what I want displayed in the legend next to the bottom element. I also want to add the initial set of points above this one.
% Sets up variable to display in the legend
Legr2Lin_R5 = compose('y = bx^m, r^2 = %.3g', r2Pwr_R5);
legend(Legr2Lin_R5,'location','se')
If I use this piece of code I get both elements within the legend, but no variable value for the second element as in the code above.
loglog(x_R4,y_R4,x_R4,Ypwr_R4,'*'),xlabel('x'),ylabel('y')
title('Using y = bx^a')
legend('Data Points','y = bx^a')
The question, how do I have both elements displayed in the legend, but also have the variable value displayed next to the second element within the legend?
I have tried a couple of things, but nothing is coming close to working.

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by