Some of Analog Filter Design block's parameters seems invalid when fetched with get_param()
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to convert an analog filter belonging to a Simulink model, into the corresponding transfer function in a Matlab script. To do this I was planning to use ss2tf(A,B,C,D) function, as the Analog Filter Design block implements the filter in state-space form.
The problem is however, when I try to get A, B, C, D matrices in Matlab script via get_param(filter, 'A'), for instance, it returns 'a' for A, 'b' for B and so on. And these lower-case letter variables are not defined in the workspace. I can get other parameters correctly.
The problem does not occur when working with State-Space block (that is genuinely added from the library and not formed by Analog Filter Design block), I can get numerical values for the matrices.
Why can't I get the matrices? Is there another way to calculate transfer function of Simulink filter?
I have uploaded a Simulink model and a script creating the problem.
0 comentarios
Respuesta aceptada
Paul
el 26 de Oct. de 2021
Two options.
Option 1:
ws = get_param(gcb,'MaskWSVariables');
ws will be 1-dimensional structure array with fields Name and Value. One element of ws, let's assume it's 6, will have ws(6).Name = 'a'. Then ws(6).Value is the A matrix. Similarly for B, C, and D. If you want to automate that, you'll have to do something like
ws(string({ws.Name})=="a").Value
Option 2:
Use the linearize() command to get the ss model of the block, then use tf if you really want the transfer function representation
sys = tf(linearlize('mdlname','blkpath'))
where mdlname is the name of the Simulink model and blkpath is the full path to the block. Or
sys = tf(linearize(gcs,gcb))
if you have the block in question selected in the Simulink model
1 comentario
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!