0% found this document useful (0 votes)
39 views4 pages

MATLAB Command Window

The document shows MATLAB code that is performing polynomial fitting and curve fitting on different datasets. It uses the minPoly and ajusteCL functions to find polynomial coefficients that minimize the least squares error between the polynomial curve and dataset points. It generates polynomials of varying degrees and plots the fitted curves along with the original data points.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

MATLAB Command Window

The document shows MATLAB code that is performing polynomial fitting and curve fitting on different datasets. It uses the minPoly and ajusteCL functions to find polynomial coefficients that minimize the least squares error between the polynomial curve and dataset points. It generates polynomials of varying degrees and plots the fitted curves along with the original data points.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

16/08/18 9:01 MATLAB Command Window 1 of 4

>> X=[-3 0 2 4]

X =

-3 0 2 4

>> Y=[3 1 1 3]

Y =

3 1 1 3

>> P=minPoly(X,Y,2)

P =

0.8505 -0.1925 0.1785

>> P=minPoly(X,Y,3)

P =

1.0000 -0.3667 0.1500 0.0167

>> P=ajusteCL(X,Y,3)

P =

2.0611 -0.0764 -1.3159

>> t=1:0.01:5;
>> r=P(1)+P(2)*t+P(3)*sin(t);
>> plot(t,r,X,Y,'o')
>> t=1:0.01:5;
>> r=P(-3)+P(0)*t+P(2)*sin(t);
Attempted to access P(-3); index must be a positive integer
or logical.

>> X=[-1 3 2]

X =

-1 3 2

>> Y=[1 0 -1]

Y =

1 0 -1

>> P=minPoly(X,Y,2)

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
16/08/18 9:01 MATLAB Command Window 2 of 4

P =

-0.5000 -1.0833 0.4167

>> X=[1 2 3 4 5]

X =

1 2 3 4 5

>> Y=[0.9 7.9 27 63.8 125]

Y =

0.9000 7.9000 27.0000 63.8000 125.0000

>> P=minPoly(X,Y,4)

P =

1.5000 -3.1750 2.0542 0.4750 0.0458

>> X=[0.1 0.4 0.5 0.7 0.7 0.9]

X =

0.1000 0.4000 0.5000 0.7000 0.7000 0.9000

>> Y=[0.61 0.92 0.99 1.52 1.47 2.03]

Y =

0.6100 0.9200 0.9900 1.5200 1.4700 2.0300

>> ajusteCL1(X,Y,3)

ans =

0.5591 1.7843 -0.4067

>> P=ajusteCL1(X,Y,3)

P =

0.5591 1.7843 -0.4067

>> t=1:0.01:5;
>> r=P(1)+P(2)*t+P(3)*sin(PI*t);
Undefined function or variable 'PI'.

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
16/08/18 9:01 MATLAB Command Window 3 of 4

Did you mean:


>> r=P(1)+P(2)*t+P(3)*sin(pi*t);
>> plot(t,r,X,Y,'o')
>> r=P(0)+P(1)*t+P(2)*sin(pi*t);
Attempted to access P(0); index must be a positive integer or
logical.

>> r=P(1)+P(2)*t+P(3)*sin(pi*t);
>>
>> X=[1.9 3.1 4.2 5.1 5.8 6.9 8.1 9.3 10]

X =

Columns 1 through 6

1.9000 3.1000 4.2000 5.1000 5.8000 6.9000

Columns 7 through 9

8.1000 9.3000 10.0000

>> Y=[0.3 0.6 0.4 0.9 0.7 1.1 1.5 1.3 1.6]

Y =

Columns 1 through 6

0.3000 0.6000 0.4000 0.9000 0.7000 1.1000

Columns 7 through 9

1.5000 1.3000 1.6000

>> ajusteCL1(X,Y,3)

ans =

-0.0272 0.1600 0.0555

>> P=ajusteCL1(X,Y,3)

P =

-0.0272 0.1600 0.0555

>> t=1:0.01:5;
>> r=P(1)+P(2)*t+P(3)*sin(pi*t);
>> plot(t,r,X,Y,'o')
>> P=minPoly(X,Y,8)

P =

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
16/08/18 9:01 MATLAB Command Window 4 of 4

1.0e+03 *

Columns 1 through 6

-0.6679 1.1512 -0.8186 0.3162 -0.0730 0.0104

Columns 7 through 9

-0.0009 0.0000 -0.0000

>>

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)

You might also like