MATLAB: Won’t the figure display a line

functionslinewontshowupnolineplotvectors

Why won't my line show up in my figure. If i don't use stars, it remains blank. Can someone explain to me what's wrong with my code? Thanks
function cosplots(x1,xN)
format compact %clear all, then formatting prevent OCD
i = 1; %intervals begin at x1
x(i) = x1; %create a vector based off of the intervals
hold on
for i = (1:xN) %loop N times to work N variables through cos
x(i+1) = cos(x(i)); % X(n+1) = cos(Xn), implemented through the loop
plot (i,x(i), '*')
end
hold off
end

Best Answer

You are only asking to draw one point at a time, so the plot has no information about which points should be connected.
If you want the points joined together then save the point locations and plot after the loop, which you can do by removing that
plot (i,x(i), '*')
line you have now and then after the loop
plot(x)