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

조회 수: 2 (최근 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