Some of Analog Filter Design block's parameters seems invalid when fetched with get_param()

2 次查看(过去 30 天)
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.

采纳的回答

Paul
Paul 2021-10-26
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 个评论
tkarg
tkarg 2021-10-26
编辑:tkarg 2021-10-26
Why do ss and afd blocks' behaviours differ? I can get numerical value of the matrices of ss block, unlike analog filter.
Edit: Ok, because of masking.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by