Basics of Matlab
The easiest way to begin learning Matlab is to start with the Command Window under the Desktop Menu.
Executing expressions in Matlab is absolutely simple !!! Just write the expression and view the results.
1) >> 3+4/10
ans =
3.4000
>>
To create a Variable
Simply write the expression
>> x=10
x =
10
>> x*x + x
ans =
110
>>
The variable is created automatically and initialized
To view the created variables write
>> x=1,y=2
x =
1
y =
2
>> who
Your variables are:
ans x y
Point to remember: There are no scalars in Matlab. Only vectors. Thus x would actually be [x].
Point to remember: To suppress an output use ; at the statements end.
Point to remember: use clc to clear the display.
>> x=5;
>> x=5
x =
5
>>
Creating Vectors
Vectors can be created in the following manners :
>> a=[1,2,3,4,5]
a =
1 2 3 4 5
>>
>> a=[1:1:10]
a =
1 2 3 4 5 6 7 8 9 10
>>
The first case is a simple enumeration, the second case specifies the starting value, the increment/decrement and the last value.
>> a=[10:-1:1]
a =
10 9 8 7 6 5 4 3 2 1
>>
We shall learn 2D and 3D plotting next.
No comments:
Post a Comment