In this tutorial we will deal with analysis of functions, interpolation, curve fitting, integrals and differential equations. Firstly, we will need to use polynomials and therefore we have to be familiar with the representation of these. A general polynomial looks like: p(x)=a_{n}x^{n} + a_{n-1}x^{n-1} +……….+ a_{1}x + a_{0 }and is represented by a vector in Matlab:

p=[ a^{n} a^{n-1} ……. a^{1} a^{0} ]

Here we have a list of basic commands dealing with polynomials.

**polyval(p,x):** Calculates the value of polynomial p for different x. If x is a vector then the polynomial is evaluated for each element in the vector x.

**poly(A):** Gives a vector that represents the characteristic polynomial for the matrix A.

**roots(p):** Gives a vector with the zeros for the polynomial p(x)=0.

**polyder(p):** Gives a vector that represents the time-derivative of the polynomial p(x). The coefficients are sored in the vector p.

**conv(p,q):** Multiplies the polynomials p and q with each other. Returns a coefficient vector.

**polyint(p):** Integrates the polynomial p analytically and uses the constant of the integration c. The constant c is assigned to 0, if it is not explicitly given.

**residue(p,q):** Makes a partial fraction expansion of p(x)/q(x).

Read more »

Tags: analysis of functions, conv, curve fitting, differential equations, double integral, double integral in matlab, integrals, integrand2, interpolation, Interpolation of data sets, local maxima, local minima, matlab maxima, matlab minima, poly, polyder, polyint, polyval, residual, residue, roots, triple integral, triple integral in matlab, triplequad

Matlab Tutorials | admin, June 20, 2009 3:33 pm | Comments (0)

In this Matlab tutorial we will deal with linear equations, the least square method, condition numbers over & under-determined equations.

Let’s start with an example.

**Example 1**

We have an equation system with three unknown variables and three equations. What will be the solution to the system below?

3w-2y+4z=8

5w+8y-6z=-5

9w-2y+7z=-17

Assume a matrix A containing the coefficients multiplied with x, y and z, and a vector with the numbers on the right-hand side of the equations. We can thus rewrite our equations as:

AX=b , where X contains the unknown (w, y and z), A and b are shown below.

b= A=
8 3 -2 4
-5 5 8 -6
-17 9 -2 7 |

How will we find the solution?

or

both gives a correct answer. The last method produces a Gaussian elimination if A is a quadratic matrix. In our case X becomes:

X=
-36.7778
71.2778
65.2222 |

This is no exact solution, only an approximation. Try also a specific command: Read more »

Tags: coefficients, complex conjugated, cubical functions, diagonal elements, differential equations, eigenvalues, eigenvectors, equation system, linear equations, linear system, linearly independent, Matlab Tutorials, quadratical functions, sparse matrices, tic, toc

Matlab Tutorials | admin, June 13, 2009 4:06 am | Comments (0)