Sunday, 31 July 2016

MATLAB Programming 41 - Some vector operations (7) (Example)

Example


Create a script file with the following code:


v = [1: 2: 20];
sv = v.* v; %the vector with elements
% as square of v's elements
dp = sum(sv); % sum of squares -- the dot product
mag = sqrt(dp); % magnitude
disp('Magnitude:'); disp(mag);


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


Magnitude:
36.4692

No comments:

Post a Comment