how can i put the type de fir1 window as input in fuction?
Show older comments
I have a function which calculates the filter coefficients,return the frequency response .... But i want to see the difference between each type of window. my function is called like this:
[c1 c9 MGhann] =CalculateFilterCoeff(N,D,hann(N),hann(N-1))
and the function is :
%----------------------------------------------------------------------------------------------
%----------------------------------------------------------------------------------------------
function [c1 c9 MargeGain] = CalculateFilterCoeff(Nelec,DinterElec,windtype1,windtype2)
w1= windtype1
w2= windtype2
%%calcul des coefficients des fitres utilisant fir1
c1 =fir1(Nelec-1,2*95*DinterElec,'low',w1);
c9 =fir1(Nelec-2,2*95*DinterElec,'high',w2);
%%Dessin des réponse fréquentielle des filtres appliqués
[h1 w1]=freqz(c1*sqrt(2),1,512);
[h9 w2]=freqz(c9*sqrt(2),1,512);
%%calcul du marge de gain entre Filtre passe-bas et passe-haut
MargeGain = []
y=find(f9>=50, 1, 'first')
MargeGain(1)=20*log10(abs(h9(y)))
end
%------------------------------------------------------------------------------------------------------------------------------------------------------------------------ %------------------------------------------------------------------------------------------------------------------------------------------------------------------------
THE PROBLEM is that i want to prevent to prevent to specify the window length (N) because in my function i want it with different length depending on the value of N. So if N is even: [c1 c9 gain] =CalculateFilterCoeff(N,D,window(N),window(N-1)) else % N is odd [c1 c9 gain] =CalculateFilterCoeff(N,D,window(N),window(N))
I can't but the type of window alone such as [c1 c9 gain] =CalculateFilterCoeff(N,D,hann) and inside the function deside which is the length because it returns that error message: ??? Error using ==> hann at 15 Not enough input arguments.
Thanks for helping to solve this problem
5 Comments
Wayne King
on 12 Dec 2013
Can you please show how you are calling CalculateFilterCoeff() at the command line?
Show us what kind of input values you want to give it. I don't understand your post as it currently stands.
Maria
on 12 Dec 2013
Wayne King
on 12 Dec 2013
so where is the windtype1 function? We need to see that.
Maria
on 12 Dec 2013
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!