Hi,
I have RPM trace signal (respiratory data) sampled at 26 Hz. I want to downsample RPM trace signal to 5.2 Hz. Does anyone know how to downsample this trace signal to 5.2 Hz?
Thanks in advance.

 Réponse acceptée

Star Strider
Star Strider le 10 Jan 2020

1 vote

I assume that the signal is sampled regularly, and a fixed sampling interval.
Use the Signal Processing Toolbox resample function. It will do exactly what you want.
A prototype call to it would be:
RPMrs = resample(RPM, 52, 260);
so the output will be sampled at 5.2/26 of the original rate.
To calculate a new time vector for it, use the linspace function.
Note that if it is not uniformly sampled, first follow the procedure in Resample a Nonuniformly Sampled Data Set, then do the rate resampling.

15 commentaires

MAT-Magic
MAT-Magic le 11 Jan 2020
Thank you very much for your kind and positive reply. It worked perfectly. Thanks once again.
Star Strider
Star Strider le 11 Jan 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
Rik
Rik le 12 Jan 2020
@Asad, You should see a button close to this answer that says 'accept answer' or something similar. You should click that button instead of flagging this comment.
copy of flag by Asad Rasheed:
This person helped me to solve my problem
MAT-Magic
MAT-Magic le 16 Jan 2020
Thanks for the kind information. I have done it
Star Strider
Star Strider le 16 Jan 2020
@Asad Rasheed — Thank you!
@Rik — Thank you!
MAT-Magic
MAT-Magic le 21 Jan 2020
Modifié(e) : MAT-Magic le 21 Jan 2020
@Star Strider, After creating new time vector as you suggested me earlier, I checked sampling intervals between any two adjacent instants of three different RPM signals, which are 0.1928s, 0.1927s, 0.1929s, while my downsampling sampling interval is 0.1923s. The three sampling intervals coming same after the decimal, but different in every case for the last digit.
Question: Will it affect when I take the final RMSE of three RPM signals?
t_new = linspace(t_previous(1), t_previous(end), length(RPMrs));
I am waiting for you kind answer. Thanks
Star Strider
Star Strider le 21 Jan 2020
As always, my pleasure.
Ideally, the time vectors should be the same. Differences could arise if the original data were not uniformly sampled (use the resample function with a different syntax to correct for that, see: Resample a Nonuniformly Sampled Data Set), or if the vectors were originally of different lengths.
The time vector should not affect the RMSE calculation, because as I recall, the time does not directly enter into that calculation. (It is the square root of the mean of the squared differences over the entire signal.) If you are subtracting one vector from another, those vectors of course have to have the same lengths and be sampled at the same time instants.
MAT-Magic
MAT-Magic le 21 Jan 2020
Thanks. I will try to use the "Resample a Nonuniformly Sampled Data Set" as resamping of my nonuniform sampled data.
Star Strider
Star Strider le 21 Jan 2020
As always, my pleasure!
MAT-Magic
MAT-Magic le 21 Jan 2020
WOW, It worked. Thanks Sir
Finally I downsampled the signal from 26 Hz to 5.2 Hz with equally spaced uniform time interval.
Star Strider
Star Strider le 21 Jan 2020
As always, my pleasure!
Nonuniformly-sampled signals require a two-step process.
MAT-Magic
MAT-Magic le 22 Jan 2020
Modifié(e) : MAT-Magic le 22 Jan 2020
@Star Srider, Thanks for the reply.
But here, my downsampling process is only one-step process by using this method "Resample a Nonuniformly Sampled Data Set" (as you suggested) which is given below in form of prototype like;
[RPMrs, tvrs] = resample(RPM, t, Fs, 3, 1);
where,
RPM = Given signal.
t = Time information of the given signal.
Fs = Downsampling frequency (5.2 Hz);
Question-1: Still I don't know how to decide the fourth and fifth arguments of above prototype in every case (especially in my case)?
Question-2: If above prototype will be the first step, then what will be second step of Nonuniformly-sampled signals?
Thanks for bearing my questions. Waiting for your kind reply. Bundle of thanks in advance.
Regards
As always, my pleasure!
First, for best results, always return the new time vector (that I call ‘tvrs’ here):
[RPMrs, tvrs] = resample(RPM, t, Fs, 3, 1);
As noted in the documentation, this resamples ‘RPM’ to the new time vector, and also upsamples it by a factor of 3/1 (determined by the last two arguments in this call to resample). If you do not want to upsample or downsample it, omit the last two arguments:
[RPMrs, tvrs] = resample(RPM, t, Fs);
That should do what you want.
MAT-Magic
MAT-Magic le 22 Jan 2020
Thank you so much Sir !!!
Star Strider
Star Strider le 22 Jan 2020
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by