Simscape global parameter set and change
18 ビュー (過去 30 日間)
古いコメントを表示
I am working with simulink and simscape inside of it. The gas domain in Simscape is what I use but I kind of need a extra parameter (D) in the gas domain that I can set with the gas properties block. What I did was create a custom gas properties block that has the new extra parameter, but I now want it accessible by other (custom) simcape blocks. I could add an output to the custom gas properties block, which is not really the problem, but I will use it in many simscape components scattered throughout the system/network as it is a global parameter. That is why I want a way to just use the parameter in other block 'inputs'/parameter sections like a value, so instead of 1 or 10 input D and then it resolves to D from gas properties.
I could theoretically make a whole new domain but this means copying all other unchanged components to match that domain instead of foundation.gas.gas which is overkill if you ask me. I also tried using memory blocks in all kind of ways but this does not work either in the easy way I imagined.
Currently the best workaround way seems to have a subsystem with a memory read. Which is coupled with a memory block in the main/top system and a dictionary which then needs to imported to every model using this which holds the original parameter D with not value given. Then set it as initial value in the memory block and adjust using memory write. This seems very unnecessary to me but nowhere can I find any documentation or references that show a better approach. And to match with what my use case is, I need to output the D parameter from the gas properties block into the memory write. So in total 3 blocks and a dictionary, together with many links are necessary to just use a 'global' parameter. I know you could theoretically set values in Matlab, but I want it accessible within Simulink/Simscape as that is where you work and simulate so it is just inconvenient to have multiple places that manage one model.
If anyone knows how to do this better please let me know.
5 件のコメント
Yifeng Tang
約11時間 前
It's easy to define a "Model Workspace" variable as part of your model. Whenever the model is opened, it's available to every block in the model, but not visible in MATLAB base workspace. This variable can have its value defined as part of the model, or using a script embedded in the model (so you can do some calculation instead of just a value). See this page: https://www.mathworks.com/help/simulink/ug/specify-source-for-data-in-model-workspace.html
Basically you define it once in the model, and it's available ... forever. Will this work?
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!