Sie sind auf Seite 1von 4

Exp.

1
Object: Determination of eigen values and eigenvectors of a square matrix. Given Matrix: 5 -3 2 A= -3 4 Command used: Results:>> a=[5 -3 2 ;-3 8 4; 4 2 -9]; >> [v,d]=eig(a) v= 0.1725 0.2382 -0.9558 d= -10.2206 0 0 0 0 0 9.7960 % diagonal elements are the eigen values 0.8706 -0.5375 0.3774 0.8429 % eigen vector, first column corresponds to eigen vector of the first eigen value 8 2 4 -9

[v , d]=eig(A)

0.3156 -0.0247

4.4246 0

>> eig(a) ans = -10.2206 4.4246 9.7960 >>[eigvec, eigval]=eig(a)

Exp-2
Object:- Determination of roots of a polynomial. Representation of a polynomial in MATLAB is illustrated below 8 x +5 8 x2-4x+10 6 x2-150 5 x 5+6 x2-7 x p=[8 5] d=[2 -4 10] u=[6 0 -150] c=[ 5 0 0 6 -7 0]

Command used: r= roots(p) where r= column vector with the roots of the polynomial and p= row vector with coefficient of the polynomial y = polyconf(p,x) Result: >> c=[ 5 0 0 6 -7 0]; >> r=roots(c) r= 0 -1.3134 0.2521 + 1.1196i 0.2521 - 1.1196i 0.8093 % evaluates the polynomial p at the values in x.

Exp-3
Object:- Determination of polynomial using method of least square curve fitting. Curve fitting:- it is process of fitting a function to a set of data points. Function can be polynomials, linear, power, exponential etc. Here we determine a polynomial that fits to a given data set Curve fitting with polynomials using least square curve fitting methods:If n data points are given, it is possible to write a polynomial of degree less than n-1 that does not necessarily pass through any of the points but overall approximate the data. A polynomial f degree n-1 pass through all the points, but it might give a large error if they are used to estimate values between the data points. Method of least square:- In this method the coefficients of the polynomial are determined by minimizing the sum of squares of the residuals at all data points. The residual at each point is defined as the difference b/w the value of the polynomial and the value of the data. Illustration:- The given data points are (x1,y1) (x2,y2) (x3,y3) (x4,y4) Find a first order polynomial that fits to this set of data. Solution:f(x)= a1x + a0

Residual at each data point Ri = f(xi)-yi Equation for sum of squares of the residuals Ri of all the data points is R= [f(x1)-y1]2 + [f(x2)-y2]2 +[f(x3)-y3]2 +[f(x4)-y4]2 = [a1x1+ao-y1]2+ [a1x2+ao-y2]2+[a1x3+ao-y3]2+[a1x4+ao-y4]2 Now to find coefficients of a1 and a0 of the polynomial take partial derivative of R with respect to a1 and ao and equating it to zero.

Solution of the two equation results in value of a1 and ao .

Command:- p = polyfit (x,y,n) Where x and y are row vectors of given data points and p is a vector of the coefficients of the polynomial that fits the data. The command uses the least square curve fitting approach to find the coefficient of the polynomial with degree n. Given data points:- (4,56) (5,78) (9,12) (13,4) (45,98) Results:>> x=[4 5 9 14 45]; >> y=[56 78 12 4 98]; >> q=polyfit(x,y,2) q= 0.2470 -11.3454 108.5942 >> t=4:0.1:50; >> z=polyconf(q,t); >> plot(t,z,x,y,'o')

160 140 120 100 80 60 40 20 0 -20 -40

10

15

20

25

30

35

40

45

50

Das könnte Ihnen auch gefallen