What is the problem in this code plz help

fs=8000;
dt=1/fs;
T=0.5;
t=0:dt:T-dt;
xt=cos(100*pi*t)-2*cos(50*pi*t);
rt=xt+cos(120*pi*t);
pa = bandstop(rt,[230 450],fs);
plot(t,pa);

11 Commenti

Dipjyoti Das
Dipjyoti Das il 30 Nov 2018
Modificato: Dipjyoti Das il 30 Nov 2018
Undefined function 'bandstop' for input arguments of type 'double'
its showing plz help
Where is the function bandstop ?
is it not a predefined function in matlab?
do you have signal processing toolbox installed?
yes..but in another question in matlab I saw he said it doesn't work in 2017 versions only work in 2018 version
Bandstop was introduced in R2018a
is there any way I can use it in 2017a?
try this function
d = designfilt();
You should get used to always using the help that comes with your Matlab rather than the online help (or at least once you have used the online help first then refer to your local help) as the online help is always for the latest version of Matlab so if you are running an older one then you may well end up trying to use functions that don't exist in your version.
plz specify how to write the function designfilt instead of bandstop
Jan
Jan il 30 Nov 2018
Modificato: Jan il 30 Nov 2018
The original question was solved: The problem of using the function bandstop, which does not exist in your Matlab version. Now you ak a new question: How to use designfilt to emulate the call of the modern bandstop . Please ask one question per thread only.

Accedi per commentare.

 Risposta accettata

For your second question: "write the function designfilt instead of bandstop":
B = designfilt('bandstopfir', 'SampleRate', 8000, ...
'PassbandFrequency1', 230, 'PassbandFrequency2', 450, ...
'StopBandFrequency1', 247.27, 'StopBandFrequency2', 432.73, ...
'StopbandAttenuation', 60, ...
'PassbandRipple1', 0.1, 'PassbandRipple2', 0.1, ...
'DesignMethod', 'kaiserwin');

3 Commenti

+1 Jan your knowledge is vast!
Jan
Jan il 30 Nov 2018
Modificato: Jan il 30 Nov 2018
@madvan: I do not have knowledge about filter design. I just opened the online help of bandpass and displayed the filter object also by catching the 2nd output.
[pa, F] = bandstop(rt,[230 450],fs);
disp(F)
Then I read the help of designfilt and found out, how to create the same object F.
Alternatively you could read the source code: type bandpass . To my surprise this works in the online help also.
So my knowledge is limited to not hesitating to use the available documentation exhaustively. ;-)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Signal Processing Toolbox in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by