Biomedical Engineering Reference
In-Depth Information
i
¼ 77.5000
12.5000
22.5000
22.5000
12.5000
A.1.4 Vectors
MATLAB stores vectors as a row vector with the first element as the i component, the
second the j component, and the third the k component, all written within brackets. For
example, the vector F
¼
3 i
4 j
þ
2 k is entered in MATLAB as
>>
F
¼
[3
4 ]
which gives
F
¼ 3
42
To calculate the magnitude of the vector, the MATLAB command “norm” is used. For
example, the magnitude of the vector F is calculated as
>>
Fmagnitude
¼
norm(F)
Fmagnitude
¼
5.3852
MATLAB also computes the dot product of two vectors with the command “dot(A,B)”. For
example, if A
¼
5 i
8 j
2 k and B
¼
6 i
þ
4 j
3 k , the dot product is computed in
MATLAB as
>>
A
¼
[5
8
2];
>>
B
¼
[6 4
3];
>>
ABdot
¼
dot(A, B)
ABdot
4
The cross product is also a built-in function in MATLAB using the command “cross(A,B)”.
For example, A
B is written as
>>
A
¼
[5
8
2];
>>
B
¼
[6 4
3];
>>
ABcross
¼
cross(A, B)
ABcross
¼
32
3
68
Search WWH ::




Custom Search