Based on your description, presumably what you are requested to plot is the value of r along one axis and the corresponding value of x, starting with 0.35, after 100 repetitions of the given iteration along the other axis. To accomplish this you will need two for-loops, one nested inside the other. The single for-loop code you wrote does not work. It should be something like this:
r = 1:.01:4;
X = zeros(1,length(r));
for k = 1:length(r)
x = 0.35;
for c = 1:100
x = r(k)*x*(1-x);
end
X(k) = x;
end
plot(r,X,'y.')
Don't be discouraged by the strange appearance of the plot you get. There will be a certain degree of apparent chaos to it. That is inherent in the nature of the iteration formula.
EDIT:
Actually you don't have to use two nested for-loops. You can write it like this:
r = 1:.01:4;
x = repmat(0.35,1,length(r));
for k = 1:100
x = r.*x.*(1-x);
end
plot(r,x,'y.')
Best Answer