MATLAB Answers

Equivalent matlab function for python librosa.resample

조회 수: 36(최근 30일)
Betty Kurian
Betty Kurian 2021년 8월 26일
댓글: Mathieu NOE 2021년 9월 2일
I need to upsample my original data of 250Hz to 96000Hz.I did it in python using librosa.resample. But when I did it in matlab I am not getting a smooth signal.I need to get an exact replica of upsampled output that I got in python.
Here i am attaching a data.mat file. In the data.mat, UL_filter is the input at sampling rate 250Hz and x is the upsampled signal which i got in python. I need to upsample the UL_filter signal @250Hz to 96000Hz and which should be same to my python output. In python, i have used the code librosa.resample(UL_filter,250,96000) and in matlab i have used resample.
To get an exact replica of python upsampled output , what function I have to use in matlab? Is there any equivalent function available in matlab for librosa.resample?

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 8월 26일
hello Betty
you can do this to upsample the data :
n = length(UL_filter);
nx = length(x);
% code for upsampling data
x_original = (0:n-1);
fs_original = 250;
fs_new = 96000;
fs_ratio = fs_new/fs_original;
x_new = linspace(0,n-1,n*fs_ratio);
upsampled_data = interp1(x_original,UL_filter,x_new,'linear');
legend('original data','upsampled data');
  댓글 수: 5
Mathieu NOE
Mathieu NOE 2021년 9월 2일
hello Betty
if my answer has fullfilled your expectations, do you mind accepting it ?

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by