Choosing specific area of points from xscale in plot

Hello everyone, I'd like to know, if there is any tool, which helps me to choose certain area from plot, returning the range of chosen area?
more specific, I have signal with 5,000,000 samples (let it be from 1 to 5M). I want to plot graph and choose the area, which I am interrested in and I need to get the range of x scale.
Example: I need to work with 10 minutes of data near the half. So I need to mark this area and recived vector, containing numbers for example from 2,458,356 to 2,534,675.
Do you have any ideas? Thanks for any help
Tom

Respuestas (2)

Giorgos Papakonstantinou
Giorgos Papakonstantinou el 11 de Mzo. de 2015
Editada: Giorgos Papakonstantinou el 11 de Mzo. de 2015
Hallo Tom. One way is to use brush/Select Data tool:
(apologize for the bad resolution).
If you want better accuracy you can do:
x = get(myplot, 'Xdata');
y = get(myplot, 'Ydata');
idx = x>=2458356 & x<=2534675; % logical indexing of the "area" you are interested
sampleX = x(idx); % x values of the area of interest
sampleY = y(idx); % y values of the area of interest.
where myplot is the handle for your plot.
i.e.
myplot = plot(..., ...)
Tom Pesek
Tom Pesek el 11 de Mzo. de 2015
Thanks for reaction Giorgos,
the thing is, that my x values are in datenum format.
the situation is like this:
and I need to get x values (red marked) to use them for ploting another signal.
So far, i did it like this:
t1 = datenum('2015-01-01 22:39:00','yyyy-mm-dd HH:MM:SS');
t2 = datenum('2015-01-01 22:59:00','yyyy-mm-dd HH:MM:SS');
m=find(time>t1 & time<t2);
myplot=plot (time(m),my_signal(m))
so now i need to mark this area and backwards recived equal cells in "time" vector.
I hope you can get the point :-/...?

5 comentarios

What is time? A cell with timestamps, a vector with numbers?
I am sorry Tom, I didn't understand this: so now i need to mark this area and backwards recived equal cells in "time" vector.
Tom Pesek
Tom Pesek el 11 de Mzo. de 2015
time is numeric array that represents each point in time - datenum function
and i would like to plot graph i showed you and choose some area (one of those horizontal parts). mark them somehow and recive the exact full numbers representing where does the marked area starts and where does it end (so it would return for example xstart = 7.359698958334053e+05; xend = 7.359699029408711e+05)
did i make it more understandable?
If you use the brush tool you can press right click and you will find an option Create variable. If you select this it will create variable in the workspace with x,y data that you have selected with brush.
If you are trying to isolate the plateau. For this you have to find a criterion. A criterion could be the numerical gradient.
tol = 0.5;
idx = abs(gradient(my_signal,time)> tol;
In this way you can target the values where you have a sudden change in your data. Thus, the beginning and the end of the plateau. You then can take the range in between for your time and my_signal variables.
Tom Pesek
Tom Pesek el 12 de Mzo. de 2015
yesss, creating variable works perfect!
thank you!!
i will keep the gradient for later too :)!
My pleasure!

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 11 de Mzo. de 2015

Comentada:

el 12 de Mzo. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by