Matlab Tutorial – Making Loops

by admin on March 25, 2014

The short video shows how loops work in Matlab. In summary:

"For" loops:
- Preferably used if you known the number of times you want to loop a command.
- If you want a loop that has a singular variable changing per loop

"While" loops:

remove junk in Huntington Park CA
junk hauling Redding CA
junk hauling in Auburn
residential junk removal Romeoville IL
junk hauling Clifton NJ
remove junk Beaumont TX
junk removal contractors Orange
junk cleaning in Fort Pierce FL
junk hauling in Huntersville NC
remove junk in Moline IL
junk removers in Lincoln CA
remove junk in Salem
debris removal in Charlotte
junk removal Waco TX
junk hauling Vancouver WA
junk removers
junk removal in Pleasanton CA
remove junk in Apple Valley
junk removal in Milpitas
junk hauling in Kearny
- Used if it is unknown the specific number of times a command needs to be looped.
- Used if you only want to run a command under certain conditions.


MATLAB Tutorial: Getting Started with MATLAB

by admin on March 23, 2014

MATLAB tutorial exploring the basics of using MATLAB. See how to enter commands, create plots, perform matrix operations and get help. Check out and learn the basics of matlab from the following video.


Matlab Tutorials for Download

by admin on March 17, 2014

I have found some free, brief, useful basic tutorial of Matlab for you to download and read. All of these tutorials are available in pdf copy. Check it out:

1) MATLAB_Tutorial.pdf - 262kb – 19 Pages.

Author – Qian Wang, Mechanical Engineering, Penn State University.

MATLAB Fundamentals
Plotting Figures
ODE Solver
Building Control Systems
Time Response
Root Locus
Frequency Response / Bode Plot


2) A Guide to MATLAB for Chemical Engineering Problem Solving – 163kb – 25 Pages

Author – Kip D. Hauch, Dept. of Chemical Engineering, University of Washington

General Introduction
What is Matlab? (Matrix Laboratory), What is Simulink?
Where to use Matlab? (Should I buy Student Matlab?)
II. Getting Started
Launching Matlab
The Workspace Environment Three types of Windows
Variables and Data entry
Matrix Operations
III. Functions (log, exp, conv, roots)
IV. Matlab Scripts and function files (M-files)
Matlab Scripts
Function files
More script writing hints
V. Problem Solving
Polynomial Curve fitting, taking a derivative
Misc. Hints
Numerical Integration
Solving simultaneous algebraic equations (fsolve)
Solution to (sets of) Ordinary Differential Equation (ode45)
VI. Input and Output in Matlab
Output 18
Exporting Data as a Tab-delimited text file
VII. Simulink




Tutorial #5 – Symbolic Integration and Differentiation

by admin on January 23, 2014

Tutorial #5 – Symbolic Integration and Differentiation

{ 1 comment }

Tutorial #4 – Numerical and Symbolic Integration, Quadrature

by admin on January 23, 2014

Tutorial #4 – Numerical and Symbolic Integration, Quadrature


Tutorial #3 – Dealing with Functions

by admin on January 23, 2014

Tutorial 3 – Matlab

Tutorial #3 – Dealing with Functions


Tutorial #2 – Matlab MFiles (Function Files)

by admin on January 23, 2014

Tutorial #2 – Matlab MFiles (Function Files)


Matlab Tutorials #1 – Getting Started

by admin on June 18, 2014

If you are new to Matlab, then you are in the correct place to learn this powerful software. I'll do my best to guide and help you.  Let's get started. Hope you'll benefit from Cheers…

(1) First, you need to have Matlab software installed in your PC or laptop.

(2) Then, click the MATLAB icon on Windows to start MATLAB command window, which gives an interactive interface.

(3) The top menu bar can be used to open or write a M-file, which will be addressed later. Once started, MATLAB will provide some introductory remarks and pop up the MATLAB prompt >>.


(4) Help Facility. By typing "help", "help <topics>", you can get on-line help.

» help
(5) The following result will appear and you can choose any topics that you need some help with.


(6) If you need help for ODE (ordinary differential equation), you can type in:

and the following help topics related to ODE will appear.


(7) Performing very simple function

Let's try an example. At the command prompt, type in x = 2.


After that click "enter" and the following will appear.


Repeat the entire process by defining y = 3 at the command prompt. The overall process is shown below:


Now, at the command prompt, type in x + y and press "ENTER". The following will appear where 2 + 3 = 5 will be shown.


(8) Saving working space

After performing a process or calculation, you might perhaps want to save the file. Terminating a MATLAB session deletes the variables in the workspace. Hence, before quitting, you can save the workspace for later use by typing "save", which saves the workspace automatically as "matlab.mat". Or, you can also choose "save workspace as" with other "filenames". For this example, I'll save it as "example1.mat".



lternatively, you can save using other methods. In this case, we save it using the selected variables. To illustrate this, at the command prompt, type

>> save temp x y


which saves the current variable "x, y" into "temp.mat" as shown in the figure below.

(9) To retrieve all the variables from the file named "temp.mat", type
» load temp

(10) Exit
Exit MATLAB by typing
» quit
» exit

Continue tutorial at Matlab Tutorials #2 – Fundamental Operations/Expressions.


Matlab Tutorials #2 – Fundamental Expressions/Operations

by admin on June 16, 2014

This tutorial is the continuity from Matlab Tutorials #1 – Getting Started.

A. Basics

MATLAB uses conventional decimal notion, builds expressions with the usual arithmetic operators and precedence rules. Please try out hands on the exercises below. Define "x" and "y". Try it out and get the feel.


Now try defining "z" and combine it with the above in the same command window.


Now try the following function.


B. Matrix Operations

Matrix operations are fundamental to MATLAB. Within a matrix, columns are separated by space, and the rows are separated by semicolon";". For a start, type in the following after the common prompt:

>> A = [1 2 3; 4 5 6; 7 8 9]

Try it out and you will see the following result.


Now, try this new exercise using "ones" in the matrix as shown in the figure below:

Be careful of the sign "[  ]" and "(  )". It you type in wrongly, the result will be an error. Try using the a "[  ]" for the previous example.

Now, try summing up "A" and "B" and the following will be produced in the matlab command window:

Did you get it? It's simple right!

Now let's try to make the inverse of the matrix A. This can be done by following the example below:

You can try to add, subtract and others using other matrix operations available in MATLAB as shown below:

+ addition
- subtraction
* matrix multiplication
^ power
‘ transpose
\ left division
/ right division

The operations, , ^, \, and /, can be made to operate entry-wise by preceding them by a period. Go ahead and try it out. It's really simple.


C. Building Matrix

Convenient matrix building functions are

eye identity matrix
zeros matrix of zeros
ones matrix of ones
diag diagonal matrix
triu upper triangular part of a matrix
tril lower triangular part of a matrix
rand randomly generated matrix

For example:

You can also built matrices from blocks. Try the following example, using "D",

Retrieving part or an element of a matrix also can be done. Check and try it out:

Other functions for colon notation:

Continue tutorial at Matlab Tutorials #3 – Fundamental Operations – Vector Matrix Function.


Matlab Tutorials #3 – Fundamental Operations – Vektor Matrix Functions

by admin on June 15, 2014

This tutorial is the continuity from Matlab Tutorials #2 – Fundamental Expressions/Operations.

Matrix Vector

Certain functions in MATLAB are "vector functions", i.e., they operate essentially on a vector (row or column). For example, the maximum entry in a matrix D is given by max(max(D)).

» max(D)
ans =
1.0000 1.0000 1.0000 0 0 0.9501
» max(max(D))
ans =

A few of these functions are:

max, min, sort, sum, prod, mean, std, any, all.


Matrix functions

The most useful matrix functions are:

eig ~ eigenvalues and eigenvectors
svd ~ singular value decomposition
inv ~ inverse
det ~ determinant
size ~ size
norm ~ 1-norm, 2-norm, F-norm
cond ~ condition number in the 2-norm
rank ~ rank

See the following example:


Continue tutorial at Matlab Tutorials #4 – Plotting Figures.