How can I insert a variable into a plot legend, with a special character following the variable?
I am attempting to create a specific legend on a plot. I am intentionally ignoring the first 3 sets of data, because I don’t want them to be labeled in the legend. I only want the legend to display the fourth data set and read: ‘Gradient: [insert variable value] °/mm’. In my case, the varibale value I am trying to display is ‘M’. I have tried a bunch of things, but have not yet been successful in displaying both the variable value and the degree symbol for the units following the variable. The following is the code I am currently trying, but is unsuccessful:
m=(y2-y1)/(x2-x1);
M=abs(m);
str=num2str(M);
legend(”,”,”,’Gradient:’,eval(str),’circ/mm’)
Any help would much appreciated. Thank you.I am attempting to create a specific legend on a plot. I am intentionally ignoring the first 3 sets of data, because I don’t want them to be labeled in the legend. I only want the legend to display the fourth data set and read: ‘Gradient: [insert variable value] °/mm’. In my case, the varibale value I am trying to display is ‘M’. I have tried a bunch of things, but have not yet been successful in displaying both the variable value and the degree symbol for the units following the variable. The following is the code I am currently trying, but is unsuccessful:
m=(y2-y1)/(x2-x1);
M=abs(m);
str=num2str(M);
legend(”,”,”,’Gradient:’,eval(str),’circ/mm’)
Any help would much appreciated. Thank you. I am attempting to create a specific legend on a plot. I am intentionally ignoring the first 3 sets of data, because I don’t want them to be labeled in the legend. I only want the legend to display the fourth data set and read: ‘Gradient: [insert variable value] °/mm’. In my case, the varibale value I am trying to display is ‘M’. I have tried a bunch of things, but have not yet been successful in displaying both the variable value and the degree symbol for the units following the variable. The following is the code I am currently trying, but is unsuccessful:
m=(y2-y1)/(x2-x1);
M=abs(m);
str=num2str(M);
legend(”,”,”,’Gradient:’,eval(str),’circ/mm’)
Any help would much appreciated. Thank you. legend, string MATLAB Answers — New Questions