MATLAB: How to compute the best first order (linear) fits of the forms y = mx+b and y = Ce^dx

line of best fitplotpolyfitpolyval

How can I compute these forms and display the values for a,b,C, and d? My code is below.
% creates a graph with a line of best fit
rideData % contains arrays of data for climb and calories
figure(1);
plot(climb, calories, "o");
p = polyfit(climb, calories, 1);
f = polyval(p, climb);
hold on
plot(climb, f);

Best Answer

What is a?
Did you see my answer here in this recent question
To display values, plug them into sprintf() and then use helpdlg(), msgbox(), text(), or fprintf() to display them.
Your p(1) is your m.
Your p(2) is your b.
To fit to an exponential, use fitnlm() like the attached example shows.