transfer function command to use in 'Matlab function block'
이전 댓글 표시
Hello friends,
I desinged IIR Bandpass filter using R,L,C values and usinf 'tf' command I got the transfer function of that filter. similarly I converted it from continuous to discrete 'c2d'.
Now I need to use this .m file for code generation. Is it possilbe to use direct m-file? If I use matlab-function block which is used to generate c/c++ code. This bloock is not accepting 'tf' command for code generation.
and similarly 'grpdelay' command is also not accepted by this block. Can anyone help me with this problem please.
function filter_tf
Ts = 1e-7 ;
Fs = 1/Ts ;
% Bandpass filter
F1 = 190000 ;
F2 = 4000000 ;
F = [F1, F2] ;
W1 = 2*pi*F1 ;
W2 = 2*pi*F2 ;
BF = (W2 - W1) ;
W0 = sqrt(W1 * W2) ;
W12 = 1/(W0 * W0) ;
Q = W0 / BF ;
Fr = sqrt(F1 * F2) ;
R = 100 ;
C = (1/(BF*R)) ;
L = (W12 / C) ;
N = 1/(R * C) ;
D1 = 1/(R * C) ;
D2 = 1/(L *C) ;
Fc = 1/(2*3.14*sqrt(L * C)) ;
RC = R * C ;
LC = L * C ;
RL = R / L ;
Wc = 1/(2 * pi * Fc);
% Implementing Continious transfer function
F1 = tf([N 0],[1 D1 D2]) ;
continnious_transfer_function_bandpass = tf(F1)
% % Continious to discrete using Bilinear Z-Transformation
discrete_transfer_function_bandpass = c2d(continnious_transfer_function_bandpass,Bandpass.Ts,'tustin')
thanks in advance
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Texas Instruments C2000 Processors에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

