Azzera filtri
Azzera filtri

Advice and ideas to "get"/"collect" the units at the ports of the Simscape blocks

3 visualizzazioni (ultimi 30 giorni)
Dear fellows:
I am trying to develop a MATLAB program where the the units at the ports (signal ports, not the physical ones since there domain can be detected) of Simscape blocks can be picked up automatically based on the handle of the block. One block under question is Fuel Cell/ Electrical Simscape.
I have tried a few thing but nothing seems to work. One thing I tried was using:
get_param(handle, 'CompiledPortUnits') but this command only gives correct results for the Simulink block and does not give the the units at the ports but only returns the handles.
Another option is each block has the units stored as parameters (image 2) and I can access from but the problem their is that each paramater name then will be unique for other blocks.

Risposte (1)

Githin George
Githin George il 26 Ott 2023
Hello,
My understanding is that you are trying to see the value of ‘units’ at the ports of various Simscape blocks, specifically for ‘Fuel Cell’ block in Simscape Electrical.
One way to access the ‘units’ property is from the properties of Simulink ‘mask’ for the corresponding block.
The following code shows how to obtain the ‘unit’ for a selected ‘Inertia’ block from its Mask.
% gcb returns the full block path name of the current block in the current system.
p = Simulink.Mask.get(gcb);
param = p.getParameter('inertia_unit');
param.Value
For different blocks, the mask parameters will differ therefore you have to check them for each block. You can view the mask by selecting a block and using the ‘ctrl+M’ shortcut.
I also suggest that you refer to the following example, where they have used ‘Fuel Cell’ block. Note that one input is in Thermal Domain and 4 inputs are Physical Signals.
In the above example it might be convenient to obtain ‘units’ from the mask of ‘PS-Constant’ block or ‘PS-Saturation’ block instead of getting it from the ‘Fuel Cell’ block.
I hope this helps.
PS:

Categorie

Scopri di più su Electrical Sensors in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by