How to add line of best fit to plot?
Show older comments
I want to add a line of best fit to my plot using the polyfit function. However, the graph turns blank when I integrate polyfit in my code. How can I change it to make polyfit work?
% original graph without line of best fit
rideData; % file that contains arrays of data/numbers for climb and calories
figure(1);
plot(climb, calories, "o");
xlabel('climb');
ylabel('calories');
% new graph with polyfit. it turns blank
rideData; % file that contains arrays of data/numbers for climb and calories
figure(1);
polyfit(climb, calories, "o");
xlabel('climb');
ylabel('calories');
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!