Sunday, 31 July 2016

MATLAB Programming 41 - Some vector operations (4)

Scalar Multiplication of Vectors


When you multiply a vector by a number, this is called the scalar multiplication. Scalar multiplication produces a new vector of same type with each element of the original vector multiplied by the number.

Example


Create a script file with the following code:


v = [ 12 34 10 8];
m = 5 * v

When you run the file, it displays the following result:


m =
60 170 50 40

Please note that you can perform all scalar operations on vectors. For example, you can add, subtract and divide a vector with a scalar quantity.


No comments:

Post a Comment