Notice! This document is currently in Archived status.
The content of this document may be incorrect or out dated.

Professor Bourman's Matlab Tutorial

EXAMPLE

size(A)
>> A=[1 2 3 ; 4 5 6 ; 7 8 1] ;  (the ";" stops A from printing on the screen)
>> size(A)

ans =

3     3

>> a=A(1,2)

a =

2

>> size(a)

ans =

1     1

>> b=A(1,:)

b =

1     2     3

>> size(b)

ans =

1     3

>> c=A(:,1)

c =

1
4
7

>> size(c)

ans =

3     1

>> B=A'                         (transpose)

B =

1     4     7
2     5     8
3     6     1

>> B=A^(-1);                    (inverse)
>> I=A*B                        (* is matrix multiplication)

I =

1.0000         0    0.0000
0.0000    1.0000    0.0000
0.0000   -0.0000    1.0000

>> C=A.*B

C =

-1.7917    1.8333   -0.3750
 6.3333   -4.1667    1.5000
-0.8750    2.0000   -0.1250

                        A dot before any operation means it will
                        be applied to each element individually.
>> B=A.^(-1)

B =

1.0000    0.5000    0.3333
0.2500    0.2000    0.1667
0.1429    0.1250    1.0000

>> C=A.*B

C =

1     1     1
1     1     1
1     1     1

Last modified: 2007/03/20 17:12:16.078000 GMT-4 by Unknown
Created: 2007/03/20 17:12:16.078000 GMT-4 by brian.r.brinegar.1.

Categories

Search

Type in a few keywords describing what information you are looking for in the text box below.

Admin Options: Edit this Document