example of vectorizinglikewise for an operation


Example of Vectorizing:

Likewise, for an operation on a matrix, a nested loop would be needed; for illustration, supposing a matrix variable mat:

[r c] = size(mat);

for row = 1:r

for col = 1:c

% do something with mat(row,col)

end

end

typically in MATLAB, this is not essential. The Numerical operations can be completed on whole vectors or matrices. For illustration, let's say that we want to multiply each and every element of a vector v by 3, and store the outcome back in v, here v is initialized as shown below:

>> v = [3 7 2 1];

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: example of vectorizinglikewise for an operation
Reference No:- TGS0174898

Expected delivery within 24 Hours