Deleting rows until a certain point

26 visualizaciones (últimos 30 días)
Christian von Spreckelsen
Christian von Spreckelsen el 18 de Mayo de 2016
Comentada: Christian von Spreckelsen el 18 de Mayo de 2016
I made a script that calculate some data and then plots it. I now want it to delete all the data up until a certain point. So to be more specific i want it to find the first 5 rows which values is greater that a certain value and then i want it to delete all data before that point and if possible i want it to delete the same amount of rows in another variable. I thought about using find(X>1,5) but i dont know how to mark that point and delete everything before that.
I have attached an image of the graph with a point that marks the beginning. Up until that point i want all data deleted.

Respuesta aceptada

Jos (10584)
Jos (10584) el 18 de Mayo de 2016
Perhaps this example can help you:
% some data
t = 1:15 ;
v = [0 0 0 0 1 2 4 8 4 2 0 -2 -4 -8 -4]
% find the point
i0 = find(abs(v) > 0,1,'first')
% selection
t2 = t(i0:end)
v2 = v(i0:end)
% show result
plot(t,v,'bo:',t2,v2,'r.-')

Más respuestas (1)

Ahmet Cecen
Ahmet Cecen el 18 de Mayo de 2016
You can find the point by something along the lines of (you also pay attention to the dimensions of vectors, I didn't):
datacheck = sign(data - threshold); % find all points bigger
highpass = conv([ones(1,5) zeros(4,1)],datacheck); % sum previous 5 points for all points
pointindex = find(highpass==5,1); % find the first point with a sum 5
Then you can erase all points earlier by simply:
data(1:pointindex)=[];

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by