
Arduino Duemilanove - Rs. 1500/- Special Discounted Price for Limited Time only!
A Starter Kit to go with your Arduino Board - Rs. 800/-
Matlab – I
This is the first edition of a series of forthcoming tutorials in Matlab.
Objective
To introduce the beginner to Matlab, Discuss Applications of Matlab & to equip him with basic knowledge required to work with Matlab.
so what is Matlab?
Matlab stands for MATrix LABoratory. It is an application for performing mathematical calculations required in different domains. It has extreme capabilities to work with multi dimensional arrays making it the tool of choice in processing for a variety of applications.
Applications of Matlab
Matlab finds applications in every domain from accounting to aerospace engineering. Our interests being in engineering, lets see some of the things it can do for us
• Help process complex signal data
o Process Images
o Process Video
o Process Audio
• Help Perform Engineering Calculation
o Calculate Angles
o Calculate Dimensions
o Calculate Area of Complex Shapes
o Map Characteristics in a multi-axis graphs/ curves
Well that isn’t an exhaustive list but that’s some of the things we will do over a period of time in this tutorial.
Section I - Getting Started with Matlab
Launch Matlab by clicking on the appropriate start menu programs. Once Matlab is open, you should see a central window named command window,
with a >> prompt.
This is the Matlab command prompt. You will be typing your commands here.
Now let's try a simple command. Type
>> a =2;
>> b = 3;
>> a + b
and Matlab will show something like ans = 5
If you got that, Congrats!, that’s the first step into the world of Matlab.
Now, if you notice towards the Right Hand Side at the top, you will find a pane named Workspace. Here you will notice a,b and ans listed with their corresponding values. This pane shows all active variables.

Now let’s try to clear one of the values. Type
>>clear a
You will see that the variable a has disappeared.
Exercise
Try replacing the arithmetic operator in the above commands.
Section II – Working with Matrices
Let’s take our learning a bit further now and work with matrices
First, let’s create a matrix. Type
>>clear all – This will clear all the variables we had used earlier.
>>a = [1 2; 3 4] – This creates a 2x2 Matrix.
Let’s see how we can create a 2x3 Matrix now
>>a= [1 2; 3 4; 5 6;] – There you go! This will create a 2x3 Matrix
Let’s move on to Matrix Operations and see how we can multiply all the values in the matrix by a constant number
>> a * 5 – This will multiply all elements of a by 5
Good! Let’s try to multiply 2 matrices
>> b = [3 4; 5 6]
>> a + b – Observe the result. The result is a pure matrix addition output.
Now we'll change this
>>a * b – This will produce pure matrix multiplication output
Now try this
>>a .* b – This will produce a multiplication result where every element in a specific position in matrix a is multiplied with another element in the same position in matrix b. This will work only with matrices of the same dimensions.
So, how do we invert a matrix, simple, type
>> a’ - this will create an inverse of the matrix
We’ll stop here for this edition of the commands. Here is some interesting stuff for you to try out
Commands for you to try:
Online help:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Workspace information:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Directory information:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
General information:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Termination:
|
|
|
|
|
|
|
|
|
Random
Matrix Generation:
|
|
|
|
|
|
|
|
|