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')
댓글 수: 3
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!