So im storing values of x, y,z at one value of r in 'results' but I want to store a 'results' for every value of r and then plot to make the coding faster, the array 'results' is replaced each time so I only get the last one. What can I do about this?
Npre = 100000000; Nplot = 100000; %Iterations
results=zeros(Nplot,4);%parameters
a=10;b=8/3; d=0.005;for r = double(18.2903:0.0001:18.2904) %%Double means the precision stays correct. do all the other ones need to be more precise too?
xold = 1; yold = 1; zold = 1; for n = 1:Npre xnew=xold+((d*a)*(yold-xold)); ynew=yold+(d*((r*xold)-(zold*xold)-yold)); znew=zold+(d*((xold*yold)-(b*zold))); xold=xnew; yold=ynew; zold=znew; endx = zeros(Nplot,1);y = zeros(Nplot,1); z = zeros(Nplot,1); x(1)=xnew; y(1)=ynew; z(1)=znew; for n = 1:Nplot-1 x(n+1)=x(n)+(d*a)*(y(n)-x(n)); y(n+1)=y(n)+(d*((r*x(n))-(z(n)*x(n))-y(n))); z(n+1)=z(n)+(d*((x(n)*y(n))-(b*z(n)))); end results(:,1)=r; results(:,2)=x; results(:,3)=y; results(:,4)=z; subplot(3,1,1) scatter(r*ones(Nplot,1), results(:,2), 1,'.','black' ) hold on; subplot(3,1,2) scatter(r*ones(Nplot,1), results(:,3),1,'.','black') hold on; subplot(3,1,3) scatter(r*ones(Nplot,1), results(:,3),1,'.','black') hold on;end
Best Answer