简体   繁体   中英

Issues plotting graph matlab

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM