Adding Initial State when Compiling Simscape Model
Show older comments
I am compiling Simscape models for use in LabVIEW. The models themselves compile and can be sucessfully run in LabVIEW using the model interface toolkit. However, I want to include initial states in a compiled model. Otherwise the model must 'find' steady state every simulation. I know I can start simscape simulations from a saved initial state, but the compiler never finds the initial state i include in the model workspace.
I can run Simscape simulations from an initial state. I can't figure out a way to intialize COMPILED simscape models. How can I do this?
If that's not possible, is it possible to set all initial states en masse before compiling?
Thanks
Answers (1)
Abhishek Chakram
on 9 Nov 2023
0 votes
Hi Jacob Wenner,
According to my understanding, you want to add an initial state when compiling a simscape model. You can use a saved operating point to initialize the model. Here are few required steps to follow:
- Create an operating point object from the model or from the simulation data using the “simscape.op.create” function.
- Set the target values and priorities for the variables in the operating point object using the “set” and “get” methods.
- Save the operating point object to a MAT-file using the “save” function.
- Load the MAT-file in the model workspace using the “load” function.
- In the Configuration Parameters dialog box, on the Simscape pane, set the Operating point source parameter to MAT-file in model workspace.
- Specify the name of the MAT-file variable that contains the operating point object in the Operating point MAT-file variable name parameter.
- Compile and run the model.
You can refer to the following documentation to know more about the functions used:
- simscape.op.create: https://www.mathworks.com/help/simscape/ref/simscape.op.operatingpoint.simscape.op.create.html
- set: https://www.mathworks.com/help/simscape/ref/simscape.op.operatingpoint.simscape.op.create.html#mw_1bd74853-402c-406b-a8be-0c041b3f1ce8
- get: https://www.mathworks.com/help/matlab/ref/matlab.system.get.html
- save: https://www.mathworks.com/help/matlab/ref/save.html
- load: https://www.mathworks.com/help/matlab/ref/load.html
Best Regards,
Abhishek Chakram
Categories
Find more on Variable Initialization 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!