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!
