필터 지우기
필터 지우기

Downsampled data exceeds the input data

조회 수: 1 (최근 30일)
Chandramouli Jambunathan
Chandramouli Jambunathan 2022년 11월 18일
댓글: Chandramouli Jambunathan 2022년 11월 18일
I have an input data sampled at 64 Hz and I want it converted to 60Hz. I tried using 'resample' function and 'downsample' function within matlab,but in both the cases the output data exceeds the input data at some sample points. For example, the input data contains angles in degrees which is under -180 deg to +180 deg, but the downsampled data contains 220 deg,which is wrong. how to avoid these?
In the attached picture, you can find all the input and output are overlayed. Can someone please help me?
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2022년 11월 18일
hello
for the resampling task , use interp1 with a new time vector defined at rate = 60 Hz
to avoid data above / below +/- 180 ° use wrap
Chandramouli Jambunathan
Chandramouli Jambunathan 2022년 11월 18일
Thank you.. interp1 expects the coordinates of the query points (i.e. xq) and I dont have specific co-ordinates or sample points for my 60Hz data output. All I wanted is to convert an array of data which is at 64Hz to 60Hz.
Now I am using 'interp' and 'decimate' functions to upscale and downsample respectively. And the Wrap function seems to help me to limit the angles.
Thank you.
But is it a bug in the 'interp' function as it gives output outside the input data range(as you can see in the graph).Ideally it should interpolate within the input data range.

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

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 11월 18일
a demo is maybe more efficient here
so the original data gets resampled at 60 Hz by using only the start / end points of the time vector of the original data (sampled at 64 Hz)
the two data sets do match visually on the graph even though the points are not on the same grid (of course)
samples=1000;
% original data at 64 Hz rate
dt1 = 1/64;
t1= 1 + (0:samples-1)*dt1;
y1 = 180*(square(t1));
plot(t1,y1,'b-*')
% resample the data at 60Hz
dt2 = 1/60;
t2= t1(1):dt2:t1(end); % NB wee use only the first and last value of t1 to create t2
y2 = interp1(t1,y1,t2);
plot(t1,y1,'b',t2,y2,'r')
  댓글 수: 2
Chandramouli Jambunathan
Chandramouli Jambunathan 2022년 11월 18일
Brilliant. Thanks for detailed explanation.
Mathieu NOE
Mathieu NOE 2022년 11월 18일
My pleasure !

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

추가 답변 (1개)

Jan
Jan 2022년 11월 18일
A linear interpolation avoids output points outside the range of input point. Use interp1 or the modern and faster griddedInterpolant .
  댓글 수: 3
Jan
Jan 2022년 11월 18일
I do not understand the meaning of "Both 'interp1' and 'griddedInterpolant' function expects specific data points". But Mathieu has show already, how to use these interpolation methods.
Chandramouli Jambunathan
Chandramouli Jambunathan 2022년 11월 18일
I misunderstood that I need to supply the sample points for 60Hz.. that's why I mentioned earlier to your post that those function expects specific data points.. but I was wrong.. Mathieu has already shown with an example and that worked. Thanks for your comments too.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by