Amplitude decrease after FIRRateConverter

2 views (last 30 days)
Yuhan Chiang
Yuhan Chiang on 15 Jan 2024
Edited: William Rose on 16 Jan 2024
I want to downsample my signal by a significant drop-off from 1600 Hz sample rate to 30. I have found that there is a huge amplitude dropoff in when I use the methods of this page: https://www.mathworks.com/help/dsp/ref/dsp.firrateconverter-system-object.html#responsive_offcanvas
Here is an illustration of what I've encountered:
I've also did some digging with a sine-wave of 30 Hz with down-sampling ratios of 15, 50, and 160. I have found that the amplitude drop-off has a correlation of the downsampling ratio. I'm unaware of the mechanisms under the tool and if anybody can give me a better idea of what's going on, it would be grately appreciated.
Sampled with 1/15 ratio
Sampled with 1/50 ratio
Sampled with 1/160 ratio
Thank you in advance,
Yuhan Chiang
  1 Comment
Jonas
Jonas on 15 Jan 2024
Edited: Jonas on 15 Jan 2024
hi,
i guess this is a problem of the used filter. also remember the nyquist theorem, so if you use a sample rate of 1600 Hz, die highest frequency component should be 800 Hz. The minimum sample rate should then be 60 Hz. 1600/60=26+2/3. Thats your maximum downsampling rate. Probably you will get earlier into the area, where the anti alising (low pass) filter already drops the amplitude of the 30Hz sine.

Sign in to comment.

Answers (1)

William Rose
William Rose on 16 Jan 2024
Edited: William Rose on 16 Jan 2024
[edit: fix spelling errors]
Please post the data file and code you used to make the initial figure.
You said you experimented with a 30 Hz sinusoid. However, your figures show a sinusoid with a period of about 0.32, i.e. frequency approximately 3 Hz, not 30 Hz. Please clarify which frequency you mean. Perhaps this will explain the results you have observed.
The code below creates a 3 Hz sinusoid, with Fs=1600 Hz, like the sinusoid in your figures. The signal is down-sampled by factors of 15, 50, and 160.
In the code below, I use functions from the DSP toolbox. The leading points of the down-sampled signal are zeros. You could discard these points, or limit the x-axis range of the plot, but I have not done that here, so you can see what is happening.
sine = dsp.SineWave(1,3,'SampleRate',1600,'SamplesPerFrame',1600);
x = sine(); % one frame
tx = (0:length(x)-1)/sine.SampleRate; % time vector
firrc1 = dsp.FIRRateConverter(1,15); % downsample by 15
y1 = firrc1(x);
FsIn = sine.SampleRate;
[delay,FsOut] = outputDelay(firrc1,FsIn=FsIn);
ty1 = (0:length(y1)-1)/FsOut-delay; % time vector
firrc2 = dsp.FIRRateConverter(1,50); % downsample by 50
y2 = firrc2(x);
[delay,FsOut] = outputDelay(firrc2,FsIn=FsIn);
ty2 = (0:length(y2)-1)/FsOut-delay; % time vector
firrc3 = dsp.FIRRateConverter(1,160); % downsample by 160
y3 = firrc3(x);
[delay,FsOut] = outputDelay(firrc3,FsIn=FsIn);
ty3 = (0:length(y3)-1)/FsOut-delay; % time vector
% plot results
figure
plot(tx,x,'k.',ty1,y1,'ro',ty2,y2,'g+',ty3,y3,'bs');
grid on; xlabel('Time (s)');
legend('Fs=1600 Hz','1600/15 Hz','1600/50 Hz','1600/160 Hz')
The figure above shows that when the downsampling factor is 160, dsp.FIRRateConverter produces only leading zero points (roughly zero), which are not helpful.
Use resample(), instead of the DSP toolbox functions:
y1=resample(x,1,15); % resample 1:15
ty1=(0:length(y1)-1)/(FsIn/15);
y2=resample(x,1,50); % resample 1:50
ty2=(0:length(y2)-1)/(FsIn/50);
y3=resample(x,1,160); % resample 1:160
ty3=(0:length(y3)-1)/(FsIn/160);
% plot results
figure
plot(tx,x,'k.',ty1,y1,'ro'); hold on
plot(ty2,y2,'gd',MarkerSize=8,MarkerFaceColor='g')
plot(ty3,y3,'bs',MarkerSize=10,MarkerFaceColor='b');
grid on; xlabel('Time (s)');
legend('Fs=1600 Hz','1600/15 Hz','1600/50 Hz','1600/160 Hz')
The results above look good, for down-sampling by 15, 50, and 160.

Community Treasure Hunt

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

Start Hunting!