How do I extract points from a plot for further computation?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Andreia dos Santos
am 12 Okt. 2017
Kommentiert: Andreia dos Santos
am 12 Okt. 2017
I have this set of points: (time, voltage). I plotted the data and now I need to pick 2 time points between which I need to make an average of voltage values. I tried using this:
[x,y] = ginput(2)
But it is not getting me time in the x vector. Any suggestion? Thank you for your time and help!
2 Kommentare
Matthew Eicholtz
am 12 Okt. 2017
What is it giving you in the x vector? I just tried it and got what I expected from ginput.
Akzeptierte Antwort
Matthew Eicholtz
am 12 Okt. 2017
Generate and plot some random data:
t = 1:1000;
x = randn(size(t))+sin(0.05*t);
plot(t,x);
Now click on the Brush/Select Data tool in the figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178640/image.png)
Draw a rectangle around the data of interest by click-and-drag:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178641/image.png)
Right-click on the selected data and choose "Create Variable" in the popup menu:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178642/image.png)
Follow the prompt to name the variable that stores the selected data, and you're good to go. The output in this example would be an Nx2 array in which the first column contains the x-axis data (time) and the second column contains the y-axis data (called x here).
Hope this helps.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!