Plotting graphs with best fit lines

4 次查看(过去 30 天)
Hello, I'm attempting to plot a "Pressure Change as a function of Voltage" with given data points. The plot should have the points, a best fit line and two lines of uncertainty on either side of the 'best fit line'. Currently my uncertainty lines are FAR below. Request assistance.
(My understanding of my jacked up legend is that there is something with my current driver and my 2020b Matlab, I'm not too worrried about that)
V=[1.000 2.000 2.500 3.000 3.500 4.000]'; %Voltage (V) with 0.05 accuracy
P=[626 948 1452 1727 1798 2001]'; %Pressure drop (Pa) +/-20
eV=0.05*ones(size(V));
eP=20*ones(size(P));
wVal=1./(eP/mean(eP));
errorbar(V, P, eP, eP, eV, eV, 'kx');
[fobj, gof]=fit(V,P,'poly1', 'Weights', wVal);
hold on
plot(fobj)
plot(range, PInt, 'b')
legend('data', 'cal curve', 'PI', 'Location', 'Northwest', 'Linewidth', 1)
title('Pressure Drop as funciton of Voltage')
xlabel('Voltage (V)')
ylabel('Pressure Change (Pa)')
axis square
box on
set(gcf, 'Color', 'w')

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by