How to interpolate the data first time they occur

조회 수: 4 (최근 30일)
Abdulkarim Almukdad
Abdulkarim Almukdad 2021년 4월 13일
댓글: Abdulkarim Almukdad 2021년 4월 13일
I have a large data of two objects moving with certain scenarios and the spacing betwen them is recorded at each 0.02 sec. the spacing values always start with 0 (no idea why, this is from the software and can't control it) then suddenly jump to 400 and reduces gradually to -600. in the range 400 to -600 there are locations where the values are increasing then decreasing again (eg. 0,400.....,285,286,287,288,289,290,291,290,289,288,287.......-600). from this data I'm having two questions. The first is how to let the function interp1 interpolate the spacing variable the first time the value occur (the real data is not interpolated as the example above). Second question is how to neglect the 0 value at the begining and to get the 0 value from the interpolation while going from 400 to -600.
The data is attached and the column of interest is column 13 (letter M in excel). I'm only interested in interpolating the data from -300 spacing to 300 spacing. The below is the code I'm using
TestOut=readmatrix('1.xlsx')
[m1,n1] = size(TestOut);
offset = 1e-11*((1:m1)'*ones(1,n1));
T4 = TestOut+offset;
clear distanceQ speedQ cc
distanceQ = -300:300; % new spacing vector with step size of 1m
for cc=1:width(T4)
speedQ(cc,:)= interp1(T4(:,13),T4(:,cc),distanceQ);
end
%Transpose the data
NewTable = array2table(speedQ.');
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 4월 13일
offset = 1e-11*((1:m1)'*ones(1,n1));
T4 = TestOut+offset;
T4 appears to be time ?
distanceQ = -300:300; % new spacing vector with step size of 1m
speedQ(cc,:)= interp1(T4(:,13),T4(:,cc),distanceQ);
You look like you are interpolating time as the independent variable, but querying at distance ??
Also, you are not skipping column 13 while doing the interpolation ?
Are you trying to figure out the first time that they are at a particular distance?
I do not understand the relationship of the other columns to the column of interest?
Abdulkarim Almukdad
Abdulkarim Almukdad 2021년 4월 13일
T4 is the same data but with offset since without this step the enique error will occur. T4(:,13) is my dependant variable called spacing and the rest variable they time, speed, acceleration, lateral spacing....... what I'm aiming at is to make a relationship between spacing and the other variables. However, I need to make the spacing integers without decimals. Therefore, I'm interpolating the data. My code is interpolating each column separately with reference to the spacing.
if you run the code for the attached file you will see data from -300 spacing to 300 spacing and all interpolations are being done correctly. Except the locations where there are repeated values (it's taking the second time the values appear, but I want it to take the first time they appear and neglect the second time), Also it takes the value of 0 as the value that appear in the data no interpolated one.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by