Difference between revisions of "MATLAB: Vector algebra"

From Robotics
Jump to: navigation, search
Line 13: Line 13:
  
 
[[File:matlab-va-vector-norm.png|400px]]
 
[[File:matlab-va-vector-norm.png|400px]]
 +
 +
 +
Corresponding to the example "Velocity of a robot" in the [[Vector algebra|vector algebra article]] a time ''t'' and a three-dimensional velocity vector ''v'' can be created. Then the distance ''s'' that the robot moves in time ''t'' can be computed as follows:
 +
 +
[[File:matlab-va-vector-example.png|400px]]

Revision as of 17:12, 23 September 2014

← Previous: Overview Matlab.png Web interface  |  MATLAB overview  |  Back to article: Vector algebra Next: Unit vectors


In MATLAB you do not not have to declare a variable and its type. The type of a variable is specified through its initialization. So you choose a name for the variable and use the equal sign to initialize it. If no semicolon is used at the end of a command, MATLAB gives feedback about the initialized variable. Otherwise no output is generated. Scalar values for example are initialized like follows:

Matlab-va-scalar.png

An n-dimensional vector is created by typing the n components in rectangular brackets. Separation of the values with space leads to a row vector while values separated with a semicolon result in a column vector.

Matlab-va-vector.png

To compute the magnitude of a vector use the command norm:

Matlab-va-vector-norm.png


Corresponding to the example "Velocity of a robot" in the vector algebra article a time t and a three-dimensional velocity vector v can be created. Then the distance s that the robot moves in time t can be computed as follows:

Matlab-va-vector-example.png