how can i put the type de fir1 window as input in fuction?
Mostrar comentarios más antiguos
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 comentarios
Wayne King
el 12 de Dic. de 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
el 12 de Dic. de 2013
Wayne King
el 12 de Dic. de 2013
so where is the windtype1 function? We need to see that.
Maria
el 12 de Dic. de 2013
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Parametric Modeling en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!