How do i plot the line of best fit?
Show older comments
So in Pressure Experiments.mat, there is (6,32) data set. I need the whole 5th row and the 6th row of this data.So I made a scatter plot of this data with :
%Load experimental data
load('PressureExperiments.mat', 'PData')
disp(PData)
%Seperating data
A = PData(5,:) %petrol pressure data
B = PData(6,:) %Number of escaping hydrocarbons
figure(1)
scatter(A,B)
How do i make a line of best fit for this? and plot the best line on the same figure?
Thanks
Accepted Answer
More Answers (1)
the cyclist
on 16 Apr 2020
0 votes
Use polyfit to find the line of best fit.
Use the plot command to plot that line
Use the hold command so that the new plot does not overwrite the scatter plot.
Categories
Find more on Log 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!