Plotting graphs with best fit lines

조회 수: 4 (최근 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
dpb
dpb 2021년 1월 15일
plot(range, PInt, 'b')
range and PInt are undefined above. Clearly, they must have been from some other dataset than that in V,P
Patrick Struszczyk
Patrick Struszczyk 2021년 1월 15일
Thank you!

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

답변 (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