The following code was written by somebody who does not know how to use MATLAB efficiently. Rewrite this as a single statement that will accomplish exactly the same thing for a matrix variable mat (e.g., vectorize this code):
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:5| Question number:28.5
All Answers
total answers (1)
[r c] = size(mat);
for i = 1:r
for j = 1:c
mat(i,j) = mat(i,j) * 2;
end
end
>> mat = mat * 2
need an explanation for this answer? contact us directly to get an explanation for this answer