How do I get stateflow to use parameters in Simulink.parameter object?

21 vues (au cours des 30 derniers jours)
Hi,
I have been looking around for a answer to this but have not found any concrete usefull information.
I have a simulink model containing a stateflow chart. In this stateflow chart I would like to use parameters from a Simulink.parameter object. I will be building the model using ert_shrlib target.
The struct looks like this:
Futhermore i have a bus defined like this (it has the two parameters im using in my test setup):
I have tried to look at the example sf_bus_demo but that seems to build the bus in simulink and then pass it to Stateflow via an input. What i would like to do is to make the parameters available in stateflow like done with non-simulink.parameters objects (see picture below):
I have tried to mess arround with adding the "ParamStruct" bus but have not been able to get it to work.
I can't seem to figure out how to do this. Maybe my understanding of how to approach this is not correct?
I have attached the small test setup im trying to get to work.
Thanks,
Ebbe Nielsen

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 20 Mar 2020
If you add a "data1" in Stateflow and specify its scope as "Parameter" and "Type" (meaning data type) as "Inherit: same as Simulink", it will automatically look for the variable "data1" in base workspace (or data dictionrary). You can then define "data1" as a Simulink.Parameter object. They will be linked.
Your "ParamStruct" is a Simulink.Bus object. In that case, define it in base workspace. In Stateflow, when you add data, specify the "type" as "Bus: ParamStruct".
  1 commentaire
Ebbe Nielsen
Ebbe Nielsen le 24 Mar 2020
Thank you very much Fangjun Jiang. This seemed to lead me on the correct path to get it to work.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by