0
Ich bin neu in MATLAB und ich versuche, die logistische Karte x = λx (1-x) für λ in [0,4] und die Ausgangsbedingung von [0,1]. Aber aus irgendeinem Grund bekomme ich immer eine wirklich komische Handlung.Logistische Karte Plotten Probleme
Ich glaube nicht, es so sein, angenommen hat. Könnte es sein, dass mein Code falsch ist?
Jede Hilfe wird tun, danke!
Mein Code:
startL = 0; # The starting value of lambda
finalL = 4; # The final value of lambda
N = 1000; # The number of values of lambda points
# between starting value and final value
# of lambda. (optional)
L = linspace(startL,finalL,N); # A row vector of N lambda
# points between startL and finalL.
M = 1000; # The number of iterations
# Loop trough the values of lambda
for k = 1:length(L)
# allocate memory for x
x = zeros(1,M+1);
x(1) = 0.3; # Initial condition: x_0, from [0,1].
results = zeros(1,M+1);
# Iteration scheme for current lamda
for m = 1:M
x(m+1) = L(k)*x(m)*(1 - x(m));
results(k,m) = x(m+1);
end;
end;
plot(L, results, 'b.');
xlabel('\lambda');
ylabel('x_n');
title('Logistic Map');
Sie sind Plotten 'results' , das ist eine 2D-Matrix, als ob es ein 1D-Vektor wäre. Die von @ben_Heo vorgeschlagene Lösung funktioniert definitiv und macht eine coole Handlung, aber ist das die Art, wie du das planen wolltest? –