MATLAB Answers

How to download polyparci file and run it with matlab code becsause there iss no polyparci command in-built of MATLAB

조회 수: 6(최근 30일)
Syed Muneeb Haider
Syed Muneeb Haider 16 Apr 2021
답변: Matt J 16 Apr 2021
clc();
xval = [4 8 11 16 17 19 21 25 32 34];
%X values as given in question
yval = [0.33 0.9 1.41 1.99 1.7 2.25 2.60 2.71 3.33 4.01];
%y values as given in question [p,S]=polyfit(xval,yval,1);
fprintf('Fitted equation of straight line to the given data is:
y=%f(x)+%f\n',p(1),p(2));
ci = polyparci(p,S);
fprintf('\n95 percent confidence inetrval for the slope coefficient is (%f,%f) and for the intercept is (%f,%f):',ci(1,1),ci(2,1),ci(1,2),ci(2,2));
y_1=ci(1,1)*xval+ci(1,2);
y_2=ci(2,1)*xval+ci(2,2);
y_3=(p(1)*xval)+p(2);
figure
plot(xval, yval, 'o')
hold on
plot(xval,y_1)
hold on
plot(xval,y_2)
hold on
plot (xval,y_3)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by