How do I find values in a matrix which are closest to an integer which is the product of a given value?

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

采纳的回答

Matt Kindig
Matt Kindig 2013-10-2
编辑:Matt Kindig 2013-10-2
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 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by