- Add a Simscape Connector block to your model and connect it to the Simscape component whose internal state you want to expose.
- In the Simscape Connector block, define custom output ports that correspond to the internal state you want to expose. You can do this by right-clicking on the Simscape Connector block and selecting Simscape > Define Custom Output Ports.
- In the Custom Output Ports dialog box, specify the name, unit, and expression for each output port. The expression should be a Simscape expression that evaluates to the internal state of the component.
- In the Simscape Connector block, set the Output FMU flag to 'on' and specify the name of the FMU output file.
- Export the model as an FMU.
- Load the FMU in your software and access the output variables that correspond to the internal state of the Simscape component.
Simscape export FMU - expose component internal variables
1 view (last 30 days)
Show older comments
I have the task of modelling and exporting from Simscape as FMU. For example, I can say I am modelling a spring mass damper
system and exporting it as FMU. I have a software at the other end, which loads the FMU and simulates it. I need to expose the
position and other information of the mass element, but don't want to add a sensor and create a FMU outport for it. Is there someway
I can expose the mass element internal information as variables in an FMU, so that they can be accessed during simulation after
export?
0 Comments
Answers (1)
Vijeta
on 5 May 2023
Yes, you can expose the internal state of a Simscape component as outputs in an FMU. To do this, you can use the Simscape Connector block, which is available in the Simscape Utilities library. The Simscape Connector block allows you to define custom outputs for a Simscape component that can be exported as FMU variables.
Here are the general steps to follow:
Also, keep in mind that exposing the internal state of a Simscape component as outputs can increase the size of the FMU and the computational cost of simulating it. So, make sure to only expose the state variables that are necessary for your application.
2 Comments
Christian Behr
on 16 May 2023
I don't have a "Simscape Connector block" in my library and can't find any documentation on it. Is a special toolbox required? Do you have some documentation on this block?
See Also
Categories
Find more on Composite Components in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!