MATLAB: Plotting f(x) as a function of x logistic map

Logistic map x_(n+1)=f(x_n); f(x_n)=r*X(1-x) so here is what I've done:
r=2.0; x(1)=0.3 f=r.*x.*(1-x)
And, matlab giving me the value of f(x)=0.4200 But the problem is when I try to plot f(x) as a function of x like this: plot(x,f,'r') The graphing window is empty. What did I do wrong here? Please help? Thanks.

Best Answer

Sumon, see the code below:
r = 2.0;
x(1) = 0.3;
N = 40;
for ii = 1:N
x(ii+1) = r*x(ii)*(1 - x(ii));
end
plot(x(1:N),x(2:N+1),'rs-')
xlabel('x_n')
ylabel('x_{n+1}')
Related Question