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

조회 수: 4 (최근 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