How do I find values in a matrix which are closest to an integer which is the product of a given value?
3 views (last 30 days)
Show older comments
I have a huge data file with time in seconds in column two which has been modified to delete all time values where the x or y coordinates (in column 3 and 4) are 0. This gives me a new data set where the time intervals are not all equal. From this data set I need to be able to find the values that have a 10 second interval and from there plot it against speed. If I had been able to use my original data set I could have found all values which are a product of 10 with no remainder but in this case it may be that I have deleted the integer values from the data set and consequently I would then end up with a 20 sec interval instead. I hope the problem is clearly explained. Does anyone have any idea how to solve this?
0 Comments
Accepted Answer
Matt Kindig
on 2 Oct 2013
Edited: Matt Kindig
on 2 Oct 2013
I think I get what you are trying to do. I think the easiest way might be to use interpolation to fill in the missing values, as multiples of 10. Something like this could work:
%time, x, and y are your current data
timei = 0:10:time(end); %interpolated time
xyi = interp1( time, [x(:),y(:)], timei, 'nearest'); %nearest-neighbor interpolation for data
%xyi is your data at 10-second intervals.
0 Comments
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!