Write a named function function y = cositer(x, n) that takes two arguments x and n and returns the n-th iteration of the mathematical function \(x\mapsto 2\cos x\text{.}\) For example, if n = 4, the result should be
x = linspace(0, 2, 2000);
hold on
for n = [4 5 30 31]
plot(x, cositer(x, n))
end
hold off
function y = cositer(x, n)
(your function goes here)
end
Remark: the command hold on refers to displaying several functions on the same plot. Normally, Matlab replaces each plot with next one. With hold on, it keeps the previous plot and draws next one over it, using a different color (unless you specify a color). At the end, hold off is used to restore the normal behavior.