Error in resampling function
Ältere Kommentare anzeigen
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 Kommentare
Mathieu NOE
am 26 Jan. 2024
It works on my side
BTW , the correct code is
x2=resample(x,5000,4800);
and not
x2=resample(x,4800,5000);
are you sure the resample function in the Signal Processing Toolbox is not hidden by a another function that has the same name in your path or working directory ?
Cheng-Ling Kuo
am 27 Jan. 2024
Bearbeitet: Cheng-Ling Kuo
am 27 Jan. 2024
It's good that you got it working, but Matlab toolbox functions don't shadow each other. They are (supposed to be) always distinguishable by the precedence rules.
It would be interesting if you went back to your original configuration and executed:
fs=4800;
t1 = 0:1/fs:1;
x = sin(t1);
x2=resample(x,4800,5000);
which resample(x,4800,5000)
That which() command will show the version of resample that is being called with the given arguments. It would be odd if it resolved to the timeseries method.
Cheng-Ling Kuo
am 28 Jan. 2024
Paul
am 28 Jan. 2024
There shouldn't be any conflict between TMW toolboxes.
If you don't mind, run these exact commands at the command prompt one at a time with the original setup.
clear all
fs=4800;
t1 = 0:1/fs:1;
x = sin(t1);
class(x)
which resample(x,4800,5000)
If yout get any error messages, please paste back into your response the sequence of commands and the output from the command window, including the entire error message (all of the red text). Make sure it's clear in your repsonse which error message follows which command. Please do not intersperse comments like "I got the error message ..." Basically, we have to see exactly what's being run and the exact results.
Cheng-Ling Kuo
am 29 Jan. 2024
Bearbeitet: Cheng-Ling Kuo
am 29 Jan. 2024
Paul
am 29 Jan. 2024
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.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

