Pregunta

I did not find anything so far to my previous problem, I have therefore tackled the problem from another angle, but I still have a little problem. Here is my code:

%%calculation of Hopff bifurcation points
k = 0;
s = 1;
uhopf = 0;

while  s < 7
    s = s + 0.02;
    k = (s-1)*exp(-s);
    uhopf = s*k;
    %fprintf('s:  %.4f, k: %.4f, uhopf: %.4f\n', s, k, uhopf);
end

f = figure;
h = plot(uhopf, k);
xlabel('uhopf');
ylabel('k');

I was just wondering why can't I have a graph? Should I use "arrays" instead?

Thank you in advance for any help.

¿Fue útil?

Solución

You are overwriting the values k and uhopf on every iteration, so your code is just plotting one point (the last one). Store each computed value in an array.

s = 1:0.02:7;
k = (s-1).*exp(-s);
uhopf = s.*k;
h = plot(uhopf, k);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top