function for_loop(max_i) % Run this function in the profiler with different max_i's to see how the % overhead of repeated MATLAB commands causes problems with this functionally % identical code. Use the profiler to check your efficiency if your code gets % slow, and be creative with using vector methods wherever possible! %% j = 1:max_i; for i = 1:max_i j(i) = j(i) ^ 2; end %% k = 1:max_i; k = k .^ 2;