Question: A function called elim() accepts a single 1D array as an argument, and returns another 1D array in which each element is equal to the

A function called elim() accepts a single 1D array as an argument, and returns another 1D array in which each element is equal to the sum of all values up to and including the current index of the new array. For example, elim([1 2 -3]) would return [130]. Below is the function template, followed by a set of code blocks to be inserted into the template at the indicated point. For each block, enter YES if will yield the desired functionality, and NO if it will not. function z = elim(x) % INSERT CODE HERE end (a) z(1) = x(1); for i = 2:x(end) z(i) = z(i-1) + x(i); end (b) z(1) = x(1); for i = 2: length(x) z(i) = z(i-1) + x(i); end (c) for i = 1: length(x) z = 2 + x(i:end) end (d) for i = 1: length(x) z(i) = sum(x(1:1)); end (e) i = 1; for y = x if i>1 z(i) = y + z(i-1); else z(i) = y; end i = i+1; end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
