P. 1
Introduction to MATLAB - Sikander M. Mirza

# Introduction to MATLAB - Sikander M. Mirza

|Views: 652|Likes:
Published by Nasir Jumani
This is an introductory Matlab how to guide by a Pakistani professor. Certainly the English is not so good, but it teach you the basics effectively. Overall, a nice beginner's tutorial.
This is an introductory Matlab how to guide by a Pakistani professor. Certainly the English is not so good, but it teach you the basics effectively. Overall, a nice beginner's tutorial.

### More info:

Published by: Nasir Jumani on Jul 20, 2010
Copyright:Attribution Non-commercial

### Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/25/2012

pdf

text

original

A matrix is essentially a two dimensional array of numbers composed of rows
and columns. A matrix can be entered in Matlab in either of the following
three ways:

(a) Using carriage return key:

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

(b) Using semicolons to indicate the next line:

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

Introduction to Matlab

25

(c) Using the range notation with semicolon:

>> A=[1:3; 4:6; 7:9];

Some matrices can be defined simply using functions. For example, the zeros
function defines a matrix with all entries zeros, the function ones defines
matrix filled with ones and rand defines a matrix with all entries random
numbers in the [0,1] range:

>> zeros(3)
ans =

0 0 0
0 0 0
0 0 0

>> ones(3)
ans =

1 1 1
1 1 1
1 1 1

>> rand(3)
ans =

0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214

The argument in each case is the size of the matrix. The same functions can
also be used for defining some non-square matrix:

>> rand(3,4)
ans =

0.4447 0.9218 0.4057 0.4103
0.6154 0.7382 0.9355 0.8936
0.7919 0.1763 0.9169 0.0579

In this case, one needs to supply two arguments, first for the number of rows
and second for the number of columns.

scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->