Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1011
ZeroList = 1;
elseif length(L) > 2
ZeroList = TestIfZeroList(L(2:end));
else
ZeroList = 1;
end
end
2) (5 points) There is a simpler way to accomplish what TestIfZeroList does in Problem 1 above. Write a new function
to accomplish the task in the following 3 steps:
Step 1: Square every number in L. The resultant list can only contain positive numbers and zeros.
Step 2: Add up every number in this new list. To do this, you may use MATLAB’s built-in “sum”
function.
Step 3: If the resultant sum is greater than 0, then there must have been at least one nonzero element in L.
Implement Steps 1-3, starting with the function header below.
else
xl = xr;
I
output
xu = xr;
xl = xr;
end
xulist(i) = xu; Xulist
3 2 Xul 3 3
tI
xllist(i) = xl;
end
end xllist 31.5 23 1 3