Error in resampling function
显示 更早的评论
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 个评论
Mathieu NOE
2024-1-26
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
2024-1-27
编辑:Cheng-Ling Kuo
2024-1-27
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
2024-1-28
Paul
2024-1-28
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
2024-1-29
编辑:Cheng-Ling Kuo
2024-1-29
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

