Home > Blockchain >  the MATLAB plot function is not plotting things
the MATLAB plot function is not plotting things

Time:09-23

I am attemping to plot a series of points on one single graph:

Klnvalue = [-1.516 -0.609 0.202 0.934 2.486 3.725 4.743 5.590];
temp = [3400 3600 3800 4000 4500 5000 5500 6000];
for i = 1:8
    eqn = ((nh^2)/(1-nh))*68.045964 == exp(Klnvalue(i));
    y = max(vpa(solve(eqn, nh)))
    x = temp(i);
    figure
    plot(x,y)
    hold on
end

But not only does eight graphs jumped out, not a single point is plotted, could you tell me why?

CodePudding user response:

If you only want 1 graph, pass something like figure(1). Also, take figure out of the loop and instead do:
figure(1), clf, hold on

 for i = 1:8
     eqn = ((nh^2)/(1-nh))*68.045964 == exp(Klnvalue(i));
     y = max(vpa(solve(eqn, nh)))
     x = temp(i);
     plot(x,y)
 end

Otherwise you waste time calling the figure each time even when it is still the current figure. Good luck!

  • Related