Suppose I want to plot a data along with it's fitted curve in a single plot. In the legend items the first item should be 'data', the first line of the second item should be 'fitted line', the second line of second item should contain fit parameters 'a' and 'b' or slope and intercept.
I tried the following, but it doesn't work
[f,gof] = fit(x,y,linearfittype);
legend(data,{'fitted curve',['a=' num2str(f.a)],['b=' num2str(f.b)],['R-squared=' num2str(gof.rsquare)]});
I tried the suggestion in the following page, but none of them work http://www.mathworks.com/matlabcentral/newsreader/view_thread/96715
I also want a line break or vertical space between the two legend items
sprintfapproach? I just posted an answer but I see that you tried it already. - Benoit_11