フィルターのクリア

Hr_type3 function in matlab

1 回表示 (過去 30 日間)
Arihant Barjatya
Arihant Barjatya 2020 年 12 月 6 日
回答済み: Sukrut Tamhankar 2020 年 12 月 9 日
I am trying to design a type 3 FIR filter and generate its amplitude response from the function Hr_type3 (mentioned in Digital processing in matlab by Proakis), but getting an error of unknown function or variable.
Can any one help me on this?
I am trying to run this code.
M = 21;
alpha = (M-1)/2;
n = 0:M-1;
hd = (cos(pi*(n-alpha)))./(n-alpha);
hd(alpha+1) = 0;
w_ham = (hamming(M))';
h = hd .* w_ham;
[Hr,w,P,L] = Hr_Type3(h);

回答 (1 件)

Sukrut Tamhankar
Sukrut Tamhankar 2020 年 12 月 9 日
Hr_Type3() is not an in-built function in MATLAB for FIR Filter design. Hence, before directly calling this function, you need to define this function in one separate M-file and save that file with the function name (i.e. Hr_Type3.m in this case) in the same folder in which the above MATLAB script is present.
Hence, the function definition (Hr_Type3.m file) looks like below (Reference: Digital Signal Processing Using MATLAB V.4 by John G. Proakis):
function [Hr,w,c,L] = Hr_Type3(h)
M=length(h);
L=(M-1)/2;
c=[2*h(L+1:-1:1)];
n=[0:1:L];
w=[0:1:500]'*pi/500;
Hr=sin(w*n)*c';
end
Then, when you call this function in your script using following line of code, you will not face any error message:
[Hr,w,P,L] = Hr_Type3(h);
I hope this information helps in resolving the issue.

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by