Re-write the following code so that it avoids using a loop. N = 10; a = zeros(1, N); b = zeros(1, N); for i = 1:N a(i) = i; b(i) = a(i) * a(i); end

  1. Re-write the following code so that it avoids using a loop.
N = 10;
a = zeros(1, N);
b = zeros(1, N);
for i = 1:N
a(i) = i;
b(i) = a(i) * a(i);
end

Answers (0)

Tags

Asked:

on 19 Feb 2019

Commented:

on 19 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!