Você está na página 1de 2

Abhay Classes for MATLAB and GATE (EE/EC/IN/ME) Do Yourself (Exercises) No.

6
Example-1: Basic Polynomial Functions
-------------poly.m-----------------% Learning polynomial functions clc format format compact p=[1 -5 6] a=roots(p) b=poly(a) c=polyval(p,[1 2 5]) fn=inline('x.^2-5.*x+6') d=fn([1 2 5]) x=0:0.2:1 y=polyval(p,x) p1=polyfit(x,y,2) p2=polyfit(x,y,1) y1=polyval(p2,x) error=y-y1

with y(0) = 0 and y(1) = 1 and then plot y as a function of x. Solution:


>> syms x y >> y = dsolve('D2y - 2*Dy -3*y = 0', 'y(0) = 0, y(1)=1', 'x') y = 1/(exp(3)-exp(-1))*exp(3*x)-1/(exp(3)exp(-1))*exp(-x) >> y = simple(y) % simplifies the expression for y y = (exp(3*x)-exp(-x))/(exp(3)-exp(-1)) >> ezplot(y, [-6 2]) %function ezplot is used for symbolic plotting >> xlabel('x') >> ylabel('y')

_____________________________________

Exercise-1 The expression for p is given in terms of the symbolic variable x as: Example-2:Learning Symbolic Expressions P = 9*x^3 6*x^2 -2*x + 15 Solve the following equations for x and Evaluate the value of p for the following values of x: y: x2-2*x-2*x*y+4*y = 0 x = -5, 3, 7.5, 15 x^2-6*x+5 = 0 Solution:
>> syms x y s >> s= solve(x^2-2*x-2*y*x+4*y, x^2-6*x+5) s = x: [2x1 sym] y: [2x1 sym] >> s.x ans = [ 1] [ 5] >> s.y ans = [ 1/2] [ 5/2] __________________________________________

Exercise-2 Evaluate the following differentiation using the symbolic tool: Y =

d 3x 2 dx

2* x 5

Further, find the value of Y at x = 5.5. Exercise-3 Find the determinant of A using symbolic tool, for = 45 degrees, where A is given as: A =

3 sin( ) cos(2 )

cos( 2 ) sin( )

Second-Order Exercise-4 Use the MATLAB symbolic tool to solve the following set of equations: 7x + 14y 6z = 95 Solve the following differential equation with the given initial 12x 5y + 9z = -50 conditions: Example-3:Solving a differential equation:

d2y dx 2

2.

dy 3. y dx

-5x + 7y + 15z =145

Abhay Classes, 137-A, Street-29, Smriti Nagar, Bhilai, e-mail: info@abhayclasses.co.in, (M) 9806870268

Abhay Classes, 137-A, Street-29, Smriti Nagar, Bhilai, e-mail: info@abhayclasses.co.in, (M) 9806870268

Você também pode gostar