Effacer les filtres
Effacer les filtres

Copying constant from stateflow model to simulink

3 vues (au cours des 30 derniers jours)
Gyanaranjan Pattanaik
Gyanaranjan Pattanaik le 24 Sep 2012
Hello,
I have a need to write an automate script, that can copy the constants used in a statemachine's Machine to a simulink model.
I am manage to get the constants from the Statemachine but could not find a method to paste to a simulink.
For e.g. load_system(ModelName); rt = sfroot; m = rt.find('-isa','Simulink.BlockDiagram','-and','Name',%modelName); constants = m.find('-isa', 'Stateflow.Data','scope','constant'); Now, I want paste the constants to a simulink model. Certainly I dont want the model workspace to do this job but diriectly in the model level in explorer.I just found some solution using clipboard,but was not successful.
It will be great if someone help me out with wayout to accomplish this.

Réponses (2)

Kaustubha Govind
Kaustubha Govind le 24 Oct 2012
I wonder if you might need to write MATLAB code such as the following to get the value of the constant, and write it to whatever workspace you like:
>> eval(constants(i).Props.InitialValue)

Siddharth
Siddharth le 30 Oct 2012
I am not sure I understand what you mean by: "Certainly I dont want the model workspace to do this job but diriectly in the model level in explorer.I just found some solution using clipboard,but was not successful.". Please elaborate.
One solution that I can see from my current understanding of your issue is:
rt = sfroot; m = rt.find('-isa','Simulink.BlockDiagram','-and','Name','%modelname'); constants = m.find('-isa', 'Stateflow.Data','scope','constant'); mdlWkspc = get_param('%modelname','modelworkspace') assignin(mdlWkspc,constants.Name, %constantValue)
Please provide details of why this solution does not meet your needs.
best, Siddharth

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by