Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Paul
Paul il 26 Ott 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 Commento
tkarg
tkarg il 26 Ott 2021
Modificato: tkarg il 26 Ott 2021
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by