Got error in resample function

I am a beginner of Matlab and I was trying to resample y by this resample function
but i got an error: " Incorrect number or types of inputs or outputs for function resample. "
please tell me what is the problem if you know. thanks a lot.
load handel.mat
y = y(:);
Fs = 8192;
fc = 2e5;
Fs_new = ceil( (Fs/2 + fc) / Fs * 2 ) * Fs;
y_resampled = resample(y,Fs_new,Fs);

5 Comments

It works here:
load handel.mat
y = y(:);
Fs = 8192;
fc = 2e5;
Fs_new = ceil( (Fs/2 + fc) / Fs * 2 ) * Fs;
y_resampled = resample(y,Fs_new,Fs)
y_resampled = 3655650×1
0.0000 0.0004 0.0009 0.0013 0.0017 0.0022 0.0026 0.0031 0.0035 0.0039
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
I am guessing that you are calling another RESAMPLE function. Please show us the complete output when you call WHICH:
which resample -all
/MATLAB/toolbox/signal/signal/resample.m /MATLAB/toolbox/matlab/timeseries/@timeseries/resample.m % timeseries method /MATLAB/toolbox/matlab/timeseries/@tscollection/resample.m % tscollection method /MATLAB/toolbox/ident/ident/@iddata/resample.m % iddata method /MATLAB/toolbox/signal/gpu/@gpuArray/resample.m % gpuArray method /MATLAB/toolbox/simbio/simbio/@SimData/resample.m % SimData method
Thanks for your kind help. Here is the output when I call WHICH:
D:\matlab_R2024\toolbox\matlab\timeseries\@tscollection\resample.m % tscollection method
D:\matlab_R2024\toolbox\matlab\timeseries\@timeseries\resample.m % timeseries method
Do you have the Signal Processing Toolbox installed and a valid license for it?
Set a breakpoint at that line and step into resample to further investigate.
problem solved. I forgot to install toolbox, thanks a lot

Sign in to comment.

Answers (1)

An alternative approach could be to creeate a timetable and then use the retime function —
load handel.mat
y = y(:)
y = 73113×1
0 -0.0062 -0.0750 -0.0312 0.0062 0.0381 0.0189 -0.0250 -0.0312 -0.0750
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Fs = 8192;
fc = 2e5;
t = linspace(0, numel(y)-1, numel(y)).'/Fs; % Create Time Vector
Fs_new = ceil( (Fs/2 + fc) / Fs * 2 ) * Fs
Fs_new = 409600
% y_resampled = resample(y,Fs_new,Fs);
ytt = timetable(seconds(t), y) % Original ‘timetable’
ytt = 73113x1 timetable
Time y ______________ __________ 0 sec 0 0.00012207 sec -0.0061568 0.00024414 sec -0.075036 0.00036621 sec -0.031169 0.00048828 sec 0.0061568 0.00061035 sec 0.038095 0.00073242 sec 0.018855 0.00085449 sec -0.025012 0.00097656 sec -0.031169 0.0010986 sec -0.075036 0.0012207 sec -0.12583 0.0013428 sec -0.1443 0.0014648 sec -0.18124 0.0015869 sec -0.19048 0.001709 sec -0.075036 0.0018311 sec -0.012698
yttrs = retime(ytt, 'regular', 'linear', SampleRate=Fs_new) % Resulting ‘timetable’ After Using ‘retime’
yttrs = 3655601x1 timetable
Time y ______________ ___________ 0 sec 0 2.4414e-06 sec -0.00012314 4.8828e-06 sec -0.00024627 7.3242e-06 sec -0.00036941 9.7656e-06 sec -0.00049254 1.2207e-05 sec -0.00061568 1.4648e-05 sec -0.00073882 1.709e-05 sec -0.00086195 1.9531e-05 sec -0.00098509 2.1973e-05 sec -0.0011082 2.4414e-05 sec -0.0012314 2.6855e-05 sec -0.0013545 2.9297e-05 sec -0.0014776 3.1738e-05 sec -0.0016008 3.418e-05 sec -0.0017239 3.6621e-05 sec -0.001847
These are part of core MATLAB, so you should have them.
.

Products

Release

R2024b

Asked:

on 9 Apr 2025

Answered:

on 9 Apr 2025

Community Treasure Hunt

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

Start Hunting!