Plotting graphs with best fit lines

조회 수: 2(최근 30일)
Patrick Struszczyk
Patrick Struszczyk 2021년 1월 15일
댓글: Patrick Struszczyk 2021년 1월 15일
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')
  댓글 수: 3
Patrick Struszczyk
Patrick Struszczyk 2021년 1월 15일
Thank you!

댓글을 달려면 로그인하십시오.

답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by