Saving for loop output ever iteration
이전 댓글 표시
I would like to save the output from the second for loop every iteration so that I can plot it vs the variable G at the end. I can't figure out the problem. The code:
% Chaos Theory - Mapping Chaotic Behavior
clc
clear all
n = 0;
size = 100; % Size of chaotic array
x = 0.5; % Initial value
xnew = zeros(101,size-1); %Initializes Array
for j = 1:101
G = 2.9 + n;
for i = 1:size-1
x(i+1) = G*x(i)*(1-x(i)); % Mapping Equation
end
xnew(i) = x;
n = n + 0.01;
% Use if animated plot is desired. Slows down simulation time.
% figure(1)
% hold on
% plot(G,x,'r.')
end
figure(1)
hold on
plot(G,xnew,'r.')
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
