resample matrix by distance

조회 수: 4 (최근 30일)
Dion Theunissen
Dion Theunissen 2021년 1월 22일
댓글: Bjorn Gustavsson 2021년 1월 22일
I need to resample a matrix [x,y,z,rad,dist] by the distance. This is a non constant frequency.
I want a frequency of 0,1 mm per sample. For now i have a distance of 162,2 mm over 118 samples, but this can vary by every single file.
I want an automatic file which resamples the matrix to a sample frequency of 0.1 mm per sample.
Can I maybe make a for loop with the resample method? And how should it look like?

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 1월 22일
편집: Bjorn Gustavsson 2021년 1월 22일
Since you have approximately 1.5 mm between samples on average you will have to do some re-interpolation of your data. This works provided the assumption that the interpolation-scheme is reasonable for your data. That is up for you to check/verify/demonstrate/argue/show/assume. This can be done something like this:
sample_dist = your_data(:,5);
dist_interp = min(sample_dist):0.1:max(sample_dist);
if dist_interp(end) < max(sample_dist)
dist_interp(end+1) = max(sample_dist);
end
data_reinterp = interp1(sample_dist,your_data,dist_interp,'pchip');
This works provided dist varies monotonically.
HTH
  댓글 수: 2
Dion Theunissen
Dion Theunissen 2021년 1월 22일
Thanks HTH,
It looks like im close but the export file (data_reinterp) is still a 118x5 file.
Do I need to couple it with the dist_interp on a way?
Thanks in advance.
Bjorn Gustavsson
Bjorn Gustavsson 2021년 1월 22일
OK, fixed the copy-n-paste error...

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by