How do I get the equation and display on the graph for line of best fit?
183 views (last 30 days)
Show older comments
Sujala Swaminathan
on 2 Jul 2020
Edited: Ameer Hamza
on 2 Jul 2020
x=[0.200 0.100 0.067 0.050 0.040 0.033 0.025];
y=[0.214 0.158 0.130 0.125 0.136 0.115 0.107];
axis([0 0.025 0 0.025]);
plot(x,y,'x');
hold on
title('lineweaver-burk plot');
xlabel('1/S');
ylabel('1/Vo ');
figure(2)
scatter(x,y);
%Plotting the line of best fit
p=polyfit(x,y,1);
x1=linspace(min(x), max(x), 100);
y1=polyval(p,x1);
plot(x1,y1,'r-', 'LineWidth',3);
X_int = roots (p);
y_int = p(2);
hold off
0 Comments
Accepted Answer
Ameer Hamza
on 2 Jul 2020
Edited: Ameer Hamza
on 2 Jul 2020
Try this
x=[0.200 0.100 0.067 0.050 0.040 0.033 0.025];
y=[0.214 0.158 0.130 0.125 0.136 0.115 0.107];
axis([0 0.025 0 0.025]);
plot(x,y,'x');
hold on
title('lineweaver-burk plot');
xlabel('1/S');
ylabel('1/Vo ');
fig = figure(2);
ax = axes();
scatter(x,y);
%Plotting the line of best fit
p=polyfit(x,y,1);
x1=linspace(min(x), max(x), 100);
y1=polyval(p,x1);
plot(x1,y1,'r-', 'LineWidth',3);
X_int = roots (p);
y_int = p(2);
eq_str = sprintf('y = %.2fx + %.2f', p);
text(min(x)+0.02, max(y)-0.01, eq_str, ... % An example of setting the position
'FontSize', 16)
0 Comments
More Answers (0)
See Also
Categories
Find more on Line 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!