- gcb:https://www.mathworks.com/help/simulink/slref/gcb.html
- get_param:https://www.mathworks.com/help/simulink/slref/get_param.html
- set_param: https://www.mathworks.com/help/simulink/slref/set_param.html
How to change a simscape block parameter from MATLAB app?
28 次查看(过去 30 天)
显示 更早的评论
There is a block for selecting the refrigerants (Two-Phase Fluid Predefined Properties (2P)). Its a simscape block. How to change the refrigerant in this block without double clicking it? I use matlab app to run the model. In the same way I need to change the refrigerant for my model using app.
0 个评论
回答(2 个)
Arjun
2024-11-5,6:34
I see that you have a Simscape block, and you want to tweak its properties using MATLAB code.
You can do so by using the “set_param” function by providing the exact path to your block, the property or parameter name you want to modify and the value that you want to assign.
To determine the path of a block, open the mode and click on the desired block. Then, execute the command “gcb” in the command line to obtain the block's path. To find the modifiable parameters, use “get_param”, which will return all parameters that can be adjusted.
Kindly refer to the code snippet below:
% get list of all the parameters that can be modified
get_param('Block_PATH','DialogParameters');
% modify the parameters
set_param('Block_PATH','Parameter_Name',values);
Kindly refer the documentation of “gcb”, “get_param” and “set_param”:
I hope this will help!
0 个评论
Yifeng Tang
2024-11-7,7:32
modelname = "myModel"; % CHANGE THIS
refrigerant = "R134a"; % CHANGE THIS.
% You may use any of the following refrigerant names in R2024b
% "Ammonia","CarbonDioxide","Isobutane","Propane"
% "R1233zdE","R1234yf","R134a","R22","R32","R404A","R407C","R410A"
props_block = modelname + "/Two-Phase Fluid Predefined Properties (2P)";
set_param(props_block,"fluid","fluids.two_phase_fluid.utilities.enum.Fluid."+refrigerant);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!