transfer function command to use in 'Matlab function block'
조회 수: 4 (최근 30일)
이전 댓글 표시
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
채택된 답변
Azzi Abdelmalek
2016년 7월 14일
The function tf is not allowed for code generation, I suppose the function c2d is also not allowed, then you need to find another way to do it. But first, you have to tell us how the the result of c2d will be used, depending on this, there maybe some suggestions
댓글 수: 6
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!