Example: MATLAB

MATLAB Online Course

Learn the basics of MATLAB® through this introductory tutorial on commonly used features and workflows.

List of other Self-Paced Online Courses:

MATLAB Examples of Numerical Programming

by Y.-K. Kim

Example codes using MATLAB built-in functions

You can download matlab code

Non-linear solver

First, define a non-linear function in the form of f(v)=0.

Then, use a non-linear equation solver fzero (). image-20230818144953414

​

Integration

Integrating discrete dataset: trapz()

Trapezoidal Method

Integrating a Function: integral(fun, a,b)

The area of the shaded region shown in the figure can be calculated by:

image

Differentiation

Differentiating discrete dataset

Differentiate a Function

Linear Equations

Solve for Ax=b

image

Polynomial fitting

Exponential Fitting

RC circuit with unknown capacitor C and resistor of 5M

a) Find the capacitance C from curve fitting b) Estimate the voltage when time=32sec

image

1st order ODE-IVP

Solve for the response of an RC circuit with a DC input. Let tau= 4.9919; Vm=11.91;

image

2nd order ODE - IVP

Solve an m-c-k system with a sinusoidal input.

Use m=10kg ; k=800 N/m; c=200 N/(m/s), f=10Hz , h=0.01, Fdc=100N.

image

Eigenvalue

What are the eigenvalues for a given m-c-k system response? Use m=10kg ; k=800 N/m; c=200 N/(m/s)

More tutorial codes

Last updated

Was this helpful?