Deleting rows until a certain point

24 次查看(过去 30 天)
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.

采纳的回答

Jos (10584)
Jos (10584) 2016-5-18
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.-')

更多回答(1 个)

Ahmet Cecen
Ahmet Cecen 2016-5-18
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)=[];

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by