Is it possible to save plotted points?

The general idea is that I am plotting a parabola and using 'r.' to plot it in red dots.
Is there a way I can save these dot/points? I need the location, and I am randomly generating the parabola so this would definitely be ideal.
If not, could I have a suggestion to best do what I am hoping to acheive? I am sure more info is needed, so please ask away and I can clarify.

Answers (1)

Rik
Rik on 19 Aug 2020
Either save the data you use to create the plot, or retrieve that data from the XData and YData properties of the line object created by plot.

7 Comments

Can I still do that if I am just calculating it via an equation?
Without iterations, I struggle to see how I can save the data.
How would I save the XData and YData?
Thank you for taking the time to respond.
What code are you using to create the plot?
This is the code:
I am using random numbers ( num = randi(1000) ) in place of the numbers provided. This is from another forum post.
x=-10:0.1:10;
y=sqrt((36-x.^2)/9);
plot(x,y)
So why can't you save x and y directly? Anyway, the code below shows what I mean.
h=plot(x,y);
x=h.XData;y=h.YData;
Thanks a lot, guys.
It appears to have the x and y saved like this:
0.000000000000000e+00 + 2.906790642616011e+02i
Is it possible to receive an integer or does this have to do with how I am generating and plotting the numbers?
That appears to be a complex number (ie, sqrt(-1)).
If you weren't expecting imaginary components, that's usually a sign that something in your analysis isn't working the way it's intended. You could extract the real part using real(x) which is 0 but I doubt that would address the real problem, unless you're expecting a complex number.

Sign in to comment.

Categories

Products

Asked:

on 19 Aug 2020

Commented:

on 25 Aug 2020

Community Treasure Hunt

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

Start Hunting!