|
Hi,
I am plotting the trajectories of the map
x(t) = 1- ru*x(t-1)^2
using the code
function out = traj(fun,x_init,ru,max_iter,r,t_step)
% % example
% % figure;fun = @(x,r) 1 - r*x*x;out = traj(fun,.4,0.5,150,1,100);
out = zeros(ru,max_iter);
%ru_vec = linspace(ru_start,ru_end,ru_steps);
format long
for j = 1:max_iter
% if j == 1
x_0 = x_init;
% end
t = linspace(r*j,r*(j+1),t_step);
for k = 1:length(t)
% if k == 1
% x_0 = x_init;
% end
x = fun(x_0,ru);
x_0 = x;
% out(j,k) = x;
end
x = fun(x_0,ru);
out(j) = x;
x_0 = x;
% plot(repmat(ru,1,length(out(:))),out(:),'b.','linewidth',2);
% hold on;
end
% plot(repmat(ru,1,length(out(:))),out(:),'b.','linewidth',2);
plot(repmat(1,length(out(j,:))),out(j,:),'.','linewidth',1);
hold on;
end
I get the error
Index exceeds matrix dimensions
any help please
|