Why won't my script (using for loops) loop and plot all 3 values?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My script is supposed to plot three graphs, each using a value of k, and loop through these values. Once run, it should plot a graph and then be able to produce the other two graphs subsequently (when any key is pressed). However, it currently remains 'paused' and no graph is produced. What should I do? Here is my script:
for k = [2.9, 3.5, 3.9]
%clear figure, and the vector a
clf; clear a;
%set up vector a, a_1 = 0.5
a = zeros(1,50);
a(1) = 0.5;
for n = 2:50
a(n) = k*a(n-1)*(1-a(n-1))
end
plot(a);
title(['k=',num2str(k)]);
%pauses the loop and waits
% for any key press to continue
pause;
end
0 comentarios
Respuestas (1)
KSSV
el 6 de Abr. de 2017
figure
hold on
for k = [2.9, 3.5, 3.9]
%clear figure, and the vector a
%set up vector a, a_1 = 0.5
a = zeros(1,50);
a(1) = 0.5;
for n = 2:50
a(n) = k*a(n-1)*(1-a(n-1))
end
plot(a);
title(['k=',num2str(k)]);
%pauses the loop and waits
% for any key press to continue
pause;
end
USe hold on
0 comentarios
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!