1 views

Uploaded by 'Jph Flores Bmx

- Eigen Vector Explaination
- WHAT TO STUDY STPM MATHEMATICS T/S PAPER 1
- DME-TEB Gujarat Program
- sostools.pdf
- Word Perfect Mathematics Documents 1
- G-7 3rd periodic test mathematics.docx
- Seismic Modeling
- Academic History
- Unit 4_Algebra and Equations
- On the Quality Estimation of Optimal Multiple Criteria Data Association Solutions
- bcom syllabus
- Notes for Cive1620 Large Type Part 1&2 Full2008 4up
- KremserEquation (1)
- Grade 10 Course Outline for Mathematics 2019 - 2020
- July 2 - 5_Eval Functins
- 07 - Polynomials
- Assignment 01
- Lab 1
- 02781070290032289
- Programming for future Engr.

You are on page 1of 11

others on an m-by-n matrix (m >= 2) .

Array Commands

find Finds indices of nonzero elements.

length Computers number of elements.

linspace Creates regularly spaced vector.

logspace Creates logarithmically spaced vector.

max Returns largest element.

min Returns smallest element.

prod Product of each column.

reshape Change size

size Computes array size.

sort Sorts each column.

sum Sums each column.

>> X = [1 0 4 -3 0 0 0 8 6];

indices = find(X)

indices =

1 3 4 8 9

>> indices = find(X>2)

indices =

3 8 9

>> length(X)

ans =

9

>> max(X)

ans =

8

>> min(X)

ans =

-3

> sort(X)

ans =

-3 0 0 0 0 1 4 6 8

>> sum(X)

ans =

16

1

>> sum(X,2)

ans =

16

>> sum(X,1)

ans =

1 0 4 -3 0 0 0 8 6

>>

>> A = linspace(1,12,4)

A=

1.0000 4.6667 8.3333 12.0000

2. Matrix Functions

Much of MATLAB’s power comes from its matrix functions. Some useful ones are:

inv inverse

poly characteristic polynomial

det determinant

size size

rank rank

[V,D] = eig(A) produces matrices of eigenvalues (D) and eigenvectors (V) of matrix

A

M = magic(n) returns an n-by-n matrix constructed from the integers 1 through n^2

with equal row and column sums. The order n must be a scalar greater than or equal to

3.

>> A=magic(3)

A=

8 1 6

3 5 7

4 9 2

>> [c d]=eig(A)

c=

-0.5774 -0.8131 -0.3416

-0.5774 0.4714 -0.4714

-0.5774 0.3416 0.8131

d=

15.0000 0 0

0 4.8990 0

0 0 -4.8990

2

3. Calculus

The Symbolic Math Toolbox provides functions to do the basic operations ofcalculus;

differentiation, limits, integration, summation, and Taylor seriesexpansion. The

following sections outline these functions.

3.1 Differentiation

diff(f)

differentiates f with respect to its symbolic variable (in this case x)

>>syms a x

f = sin(a*x)

diff(f)

f=

sin(a*x)

ans =

a*cos(a*x)

diff(f,a)

which returns df / da

ans =

cos(a*x)*x

diff(f,2)

or

diff(f,x,2)

which return

ans =

-sin(a*x)*a^2

3.2 Limits

The fundamental idea in calculus is to make calculations on functions as a

Variable“getscloseto”orapproachesacertainvalue. Recallthatthedefinition

of the derivative is given by a limit

provided this limit exists. The Symbolic Math Toolbox allows you to computethe

limits of functions in a direct manner.

>>syms h n x

limit( (cos(x+h) - cos(x))/h,h,0 )

ans =

-sin(x)

And

3

limit( (1 + x/n)^n,n,inf )

ans =

exp(x)

In the case of undefined limits, the Symbolic Math Toolbox returns NaN (not a

number). The command

limit(1/x,x,0)

or

limit(1/x)

returns

ans =

NaN

the options for the limit command in this table. Here, we assume that f is a

function of the symbolic object x.

lim f ( x ) Limit(f)

x 0

lim f ( x ) Limit(f,x,a)

x a

lim f ( x ) Limit(f,x,a,’left’)

x a

x a

3.3 Integration

int(f)

We can do this in (at least) three different ways. The shortest is:

>>int(’xˆ2’)

ans =

1/3*xˆ3

Alternatively, we can define x symbolically first, and then leave off the single quotes

in theint statement.

>>syms x

>>int(xˆ2)

ans =

1/3*xˆ3

4

Mathematical Operation MATLAB Command

int(x^n) or

int(x^n,x)

>>int(sin(2*x),x,0,pi/2)

ans =

1

g=

cos(a*t + b)

>>int(g)

ans =

sin(b + a*t)/a

4.Solving Equations

If S is a symbolic expression,solve(S)attempts to find values of the symbolic variable

in S (as determined byfindsym) for which S is zero. For example,

>>syms a b c x

S = a*x^2 + b*x + c;

solve(S)

ans =

-(b + (b^2 - 4*a*c)^(1/2))/(2*a)

-(b - (b^2 - 4*a*c)^(1/2))/(2*a)

Ifyouwanttosolveforaspecificvariable,youmustspecifythatvariableasanadditional

argument. For example, if you want to solve S for b, use thecommand

>> b = solve(S,b)

b=

-(a*x^2 + c)/x

Note that these examples assume equations of the form f(x) = 0. If you needto solve

equations of the form f(x)=q(x) you must use quoted strings. Inparticular, the

command

s = solve('cos(2*x)+sin(x)=1')

s=

0

pi/6

(5*pi)/6

5

4.1 Several Algebraic Equations

Now let’s look at systems of equations. Suppose we have the system

and we want to solve for x and y. First create the necessary symbolic objects.

There are several ways to address the output of solve. One is to use a two-output call

>>syms x y alpha

>> [x,y] = solve(x^2*y^2, x-y/2-alpha)

x=

alpha

0

y=

0

(-2)*alpha

The equations are specified by symbolic expressions containing theletter D to denote

differentiation. The symbols D2, D3, ... DN, correspond to thesecond, third, ..., Nth

derivative, respectively. Thus, D2y is the Symbolic Mathof

The dependent variables are those preceded byD and the default independent variable

is t. Note that names of

symbolicvariablesshouldnotcontainD.Theindependentvariablecanbechangedfromt to

some other symbolic variable by including that variable as the last inputargument.

Initial conditions can be specified by additional equations. If initial conditions

are not specified, the solutions contain constants of integration, C1, C2, etc.

The output from dsolve parallels the output from solve. That is, you can call

D solve with the number of out put variables equal to the number of dependent

variables or place the output in a structure whose fields contain the solutions

of the differential equations.

Example 1

The following call to dsolve

dsolve('Dy=1+y^2')

The output of this command is

>>dsolve('Dy=1+y^2')

ans =

i

-i

tan(C4 + t)

6

To specify an initial condition, use

y = dsolve('Dy=1+y^2','y(0)=1')

y=

tan(t+1/4*pi)

not. Thus, the command diff(y,t) returns an error. To place t in the workspace, type

syms t.

Solving Equation

simultaneous linear equations. In matrix notation, this problem can be stated as

follows.

X1 2X 2 X 3 1

2 X 1 6 X 2 4 X 3 2

X 1 3X 2 3X 3 1

a vector b by

1 2 1 1

A 2 6 4 ; b 2

1 3 3 1

AX b

A = [ 1 2 -1; -2 -6 4 ; -1 -3 3 ]

b = [ 1; -2; 1 ]

X = A\b

X1 1

X 2

2

X 3 2

7

7. Polynomial Roots and Characteristic Polynomial

If p is a row vector containing the coefficients of a polynomial, roots(p) returns a

column vector whose elements are the roots of the polynomial. If r is a column vector

containing the roots of a polynomial, poly(r) returns a row vector whose elements are

the coefficients of the polynomial.

S 6 9S 5 31.25S 4 61.25S 3 67.75S 2 14.75S 15

The polynomial coefficients are entered in a row vector in descending powers.

The roots are found using roots.

r = roots(p)

r=

-4.0000

-3.0000

-1.0000 + 2.0000i

-1.0000 - 2.0000i

0.0000 + 0.5000i

0.0000 - 0.5000i

If we want to find the coefficient of polynomial that has the roots-1, -2, -3 j4.

We write this

r = [-1 -2 -3+4i -3-4i ]

p = poly(r)

p=

1 9 45 87 50

S 4 9S 3 45S 2 87S 50 0

8

Polynomial Evaluation

powers, the polyval(c, x) is the value of the polynomial evaluated at x. For example,

to evaluate the above polynomial at points 0, 1, 2, 3, and 4, use the commands

>> c = [1 2 3 1];

x = 0:1:4;

y = polyval(c, x)

y=

1 7 23 55 109

You may use the following functions; try to find out its function

Polyval,polyvalm

8. Laplace Transformation

function called (laplace) which transfer a function from time-domain to S-

Domain.Befor you use this function you must declare the variable by

symsfunction,see the below examble

>>syms t

>>laplace(t^5)

ans =

120/s^6

To get the laplaceinverse it is very easy also, only use ilaplace after decler the

variable

>>syms s

ilaplace(1/(s-1))

ans =

exp(t)

9

Consider the following transfer function:

2S 3 5S 2 3S 6

S 3 6S 2 11S 6

we write

num=[2 5 3 6]

den=[1 6 11 6]

[r,p,k]=residue(num,den)

r

-6

-4

3

p

-3

-2

-1

k

2

Which mean

6 4 3

2

S 3 S 2 S 1

10

Exercise

g ( x) (1 2 x 2 ) exp( x 2 )

(b.) Test that your function works correctly when x is a vector by evaluating

X =[2 3 4 5 0 ]

(c.) Plot your function for 3 x 3 using both fplot and the plot command

(learn more about fplot).

12S

a. ( S 9)

2 2

b. S ( S 6) 2

4- solve

7- solve

8-solve ( ) ( )

11

- Eigen Vector ExplainationUploaded byHimanshu
- WHAT TO STUDY STPM MATHEMATICS T/S PAPER 1Uploaded bySK
- DME-TEB Gujarat ProgramUploaded bySunita Mohanan
- sostools.pdfUploaded bypalasscribd
- Word Perfect Mathematics Documents 1Uploaded byRobert Kimera
- G-7 3rd periodic test mathematics.docxUploaded byLhot Bilds Siapno
- Seismic ModelingUploaded byMohand76
- Academic HistoryUploaded byDrunkDracula69
- Unit 4_Algebra and EquationsUploaded byAngeles Martin
- On the Quality Estimation of Optimal Multiple Criteria Data Association SolutionsUploaded byDon Hass
- bcom syllabusUploaded byRam Singh Kamboj
- Notes for Cive1620 Large Type Part 1&2 Full2008 4upUploaded bysjeyarajah21
- KremserEquation (1)Uploaded byAjay Shekhawat
- Grade 10 Course Outline for Mathematics 2019 - 2020Uploaded byIza Izay Izang
- July 2 - 5_Eval FunctinsUploaded byMark Geronimo
- 07 - PolynomialsUploaded byCAROL_X1
- Assignment 01Uploaded byIshaan Ahuja
- Lab 1Uploaded byKal Sommy
- 02781070290032289Uploaded byHassan Saleh
- Programming for future Engr.Uploaded byPeter Onyebuchi
- 9E62C67E-B00D-54A2-CCDD99CBFE6050DF_61280Uploaded by林琪雯
- MATH0301-Translating Sentences Into EquationsUploaded byRonna Yap
- ExponentialUploaded byabcdfr2
- CompendiumUploaded byrsasmus
- ACFrOgDv2IDe8-VSAoE2fep2wQviA951-sriuyVk8v-X4K_-EfRIMMZo-cQVc9O2uM28yb23IdHuSTFMK5q58jo39vLXdaFz8PWD_3uXQi01UqIWlRkw8FifjGtD6qs=.pdfUploaded byjatin uppal
- Singular Value Decomposition Example1Uploaded byawekeu
- unit plan-unit test-revisedUploaded byapi-234882491
- cha6Uploaded bybobby1990s
- Caam Rice Edu Caam440 Ch2Uploaded byRaymundo Cordero
- Alg 1 - Lesson 1.9 - Unit 5.docxUploaded byByron Adriano Pullutasig

- BC0052 - Theory of Computer ScienceUploaded byKareem Guzman
- ma691_ch1.pdfUploaded byham.karim
- GENG2140 2010 Condition NumberUploaded byRelene Wei
- Exercise for Signal and SystemsUploaded byNikesh Bajaj
- DesUploaded bykesavaero1
- 4. hoeffdingUploaded byGauravJain
- Solutions Ch 03Uploaded byJoonKwon
- Quiz 04sle Gaussianelimination SolutionUploaded byAnonymous WjGf1l
- CalculatorUploaded byRahul Shrivastava
- 6.6 Function Operations.pptUploaded byCristy Pearl S. Garcia
- Dynamic Programming, TopCoder tutorialsUploaded byThomas Ramos
- Basis FunctionsUploaded byrodwellhead
- c3.6 DifferentiationUploaded byMasha Iwqedwe
- Pilar Yañez Control7Uploaded byJaviera Romero
- Symmetric matrixUploaded byRaúl Ruiz
- Improved K-means clustering on HadoopUploaded byEditor IJRITCC
- Complex VariablesUploaded bySonali Vasistha
- Graph Theory App to EconomicsUploaded byAnkit Agrawal
- FEA Quiz 1solutionUploaded byRaja Aero
- 1-s2.0-0166218X81900135-mainUploaded byzabroma1717
- Social and Web AnalyticsUploaded byParvesh
- Discrete MathUploaded byAkanshaJain
- MATH-9Uploaded byEMMA C. EBORRA
- Quasi-Orders and Semilattice Decompositions of Semigroups (a Survey)Uploaded bymciricnis
- BFS CorrectnessUploaded byandrey_dung
- Orthogonality relations for the associated Legendre functions of imaginary orderUploaded byvlava89
- c05 Net ModelsUploaded byRaunak Timilsina
- Universal Bounds for Codes and DesignsUploaded bybudishin
- Partion of MatrixUploaded byNamdev
- 1441998861Projection.pdfUploaded byRicardoPedraza