1

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?

2
  • 3
    plot by default plots lines, and you are passing it a single point per iteration. Maybe substitute plot(x,y,'+'), or call plot just once outside the for-loop? Also, each call to figure creates a new figure; put that outside the loop. Commented Sep 22, 2022 at 18:38
  • 2
    Do y(i) = ... inside the loop, then plot(temp, y) after the loop. Commented Sep 22, 2022 at 19:24

1 Answer 1

2

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.