Some remarks about variables

First we recall some parts of Chapter 1. Variables in MATLAB are stored as arrays. You can access the contents of these arrays elementwise. A colon (:) indicates a whole row or column.
>> A = [1 2;3 4]

A =
    1     2
    3     4

>> A(2,1)

ans =
    3

>> A(:,2)

ans =
    2
    4

>> A(1,:)

ans =
    1     2
Variables in MATLAB have the following properties: You cannot give your own files an arbitrary name. MATLAB commands like for or end, but also e.g. plot, prod and eig can not be chosen. Sometimes you do not get a real error message, but just false results. Be careful with this, give your program a unique name.



Previous      Next      Up      Contents


Esteur 2010-03-22