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.

Antworten (1)

Rik
Rik am 19 Aug. 2020

0 Stimmen

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 Kommentare

Kayleigh Movalli
Kayleigh Movalli am 19 Aug. 2020
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.
Rik
Rik am 19 Aug. 2020
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;
Kayleigh Movalli
Kayleigh Movalli am 25 Aug. 2020
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?
Adam Danz
Adam Danz am 25 Aug. 2020
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.

Melden Sie sich an, um zu kommentieren.

Produkte

Gefragt:

am 19 Aug. 2020

Kommentiert:

am 25 Aug. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by