MATLAB: Adding extra information into a graph which is text

appdesignerlegend

So for my appdesigned matlab gui i am plotting the data in the axes. I want to show the rsquare values of 3 models along with plotting the model outcome. However , I am unable to figure out how can I enter the rquare numbers as text into the legend entry box?

Best Answer

Use sprintf()
legendText1 = sprintf('r squared for model 1 = %f', rSquared1);
legendText2 = sprintf('r squared for model 2 = %f', rSquared2);
legendText3 = sprintf('r squared for model 3 = %f', rSquared3);
legend(legendText1, legendText2, legendText3);
Related Question