필터 지우기
필터 지우기

Error in resampling function

조회 수: 77 (최근 30일)
Cheng-Ling Kuo
Cheng-Ling Kuo 2024년 1월 26일
댓글: Paul 2024년 1월 29일
I try to change sampling rate from 4.8kHz to 5kHz
fs=4800;
t1 = 0:1/fs:1;
x = sin(t1);
x2=resample(x,4800,5000);
But I get error
Incorrect number or types of inputs or outputs for function resample.
How to solve it?
Even I used
[p,q]=rat(5000/4800)
x3=resample(x,p,q);
It seems the same error!
  댓글 수: 7
Cheng-Ling Kuo
Cheng-Ling Kuo 2024년 1월 29일
편집: Cheng-Ling Kuo 2024년 1월 29일
I got the following message.
fs=4800;
t1 = 0:1/fs:1;
x = sin(t1);
class(x)
which resample(x,4800,5000)
ans =
'double'
'resample(x,4800,5000)' not found.
Paul
Paul 2024년 1월 29일
So, if trying to execute that resample command it resolves to the timeseries method. But the which command doesn't find anything. No idea what could be the problem.

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

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024년 1월 28일
If you want to use fs = 5000 Hz, then the command syntax has to be resample(x_siganl, time, fs_new) This is how it should be done:
fs=4800;
t1 = 0:1/fs:1;
x = sin(t1);
fs_new = 5e3;
x2=resample(x,t1,fs_new);
which resample(x,t1,fs_new)
/MATLAB/toolbox/signal/signal/resample.m
scatter(t1, x)
hold on
t2 = 0:1/fs_new:1;
scatter(t2, x2(1:end-1))
legend('Original Data', 'Resampled Data', 'Location', 'Best')
grid on
xlabel('t')
ylabel("x & x_{resampled}")
%% View a small portion of the data:
figure
scatter(t1, x)
hold on
t2 = 0:1/fs_new:1;
scatter(t2, x2(1:end-1))
legend('Original Data', 'Resampled Data', 'Location', 'Best')
grid on
xlabel('t')
ylabel("x & x_{resampled}")
xlim([0.95 1])

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by