Could anybody help to solve the issue.

I want to plot the graph for the command line
plot(rng,final1,'-rs');
when i run the code the values of rng and final1 displayed in the command window as :
rng = 1
final1 =1.8635e+10
rng = 2
final1 =2.0387e+10
rng = 23
final1 =2.1245e+10
But i am getting the graph as attached.In the graph the final1 values remain fixed with respect to different values of rng. could anyone help me to plot the graph for corresponding values of rng and final1.

 Accepted Answer

Why don't you try this?
rng=[1 2 23]
final=[1.8635e+10 2.0387e+10 2.1245e+10]
plot(rng,final,'-rs');grid on

10 Comments

that command line works fine.But in my code i will be using different values of rng.Based upon the rng values final values will be generated while running the code.thats the reason i am not using command line mentioning values as it keeps on changing.
I would like to check with you if the values are being displayed in the command window why it is not able to plot those values in the graph using the command line plot(rng,final,'-rs');.Could you please tell me.
rng = 1
final1 =1.8635e+10;
plot(rng,final1,'o');hold on;grid on
rng = 2
final1 =2.0387e+10
plot(rng,final1,'o');
rng = 23
final1 =2.1245e+10
plot(rng,final1,'o');
thanks.the above command works. But what i really need is final1 values cannot be mentioned.As final1 values will be generated while the code executes.Final1 values needs to taken directly when the main code executes.Is there any other way that contains without mentioning the final1 values.

Ok, then put the plot command right after final1 is generated. You do not need to display it.

I have used the plot command after the final1 is generated but the graph generated still not correct. I am getting three graphs where final1=1.8842e+10 for rng=1,2and 23 ,final1 = 1.9400e+10 for rng =1,2 and 23 and final=1.8121e+10 for rng=1,2,and 23.

Use hold on command after plot command to see them in one figure.

still i am getting 3 graph for the results rng = 1 final1 =1.8635e+10 rng = 2 final1 =2.0387e+10 rng = 23 final1 =2.1245e+10

This will give you one graph:

rng = 1; 
final1 =1.8635e+10;
plot(rng,final1,'o');hold on;
rng = 2; 
final1 =2.0387e+10;
plot(rng,final1,'o');
rng = 23;
final1 =2.1245e+10;
plot(rng,final1,'o');

or my initial answer:

 rng=[1 2 23]
 final=[1.8635e+10 2.0387e+10 2.1245e+10]
 plot(rng,final,'o');grid on

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!