# Trimming multiple plots down to same time frame

8 views (last 30 days)
Janell Lopez on 14 Apr 2017
Answered: Sam McDonald on 19 Apr 2017
I have a lab in which we take thrust data from a static test stand. We are then supposed to trim the data down to only the portion of time during which the thrust occurred. The data is given in vectors of Newtons versus time. Here is one set of data plotted (time is in seconds):
I need to cut it down, from the point where it begins to increase sharply (just before t=3) to the sharp point of the curve on the other side--not the lowest value, but the value just before the smooth curve back up to zero. I had originally just zoomed in on the plot and selected these values by hand, but now I need to do the same process for 33 sets of data in vectors. Here is a plot of all of these thrust data sets in one (axes are the same as before):
So I was trying to find something they all have in common, for a start point and an end point, to put in a for loop or an if-else statement and be able to run through and trim all the data down to only the thrust curves. The problem is that the thrust portion of the curve doesn't begin at the same time for all of them, the noise is fairly high so the data crosses zero multiple times, and the minimum values at the end of the curve vary so much that I'm not sure how to find something that won't cut off half of them early. I just need a way to trim the data and I am out of ideas!
Thank you,
Janell

Sam McDonald on 19 Apr 2017
I see two options. You can either 1) plot all the data and simply set the axis limits to only show the data you want to, or 2) trim the data so that you are only plotting data that you want to see.
For option 1) take a look at the "axis" function to set/get axis limits. You will need to determine the desired min and max time values for the x axis. To do this, consider using the "find" function with you own logic to find those values.
For option 2) you can use logical indexing to only plot a subset of the data that satisfies a given condition. For example:
t = 0:0.01:pi;
x = sin(t);
cutoff = 0.4;
plot(t(x>cutoff),x(x>cutoff));
It seems like the tricky part in your case is to figure out what condition you want. You could check the absolute value cutoff and implement a buffer of time to ensure that you are not trimming too late or too soon.