- Mass & Energy Flow Rate Sensor (2P): https://www.mathworks.com/help/simscape/ref/flowratesensor2p.html
- PS Subtract: https://www.mathworks.com/help/simscape/ref/pssubtract.html
How to access internal variables of Simscape blocks from Simulink using sensors
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 15 de Dic. de 2022
Editada: MathWorks Support Team
el 31 de Mzo. de 2024 a las 20:58
I am using the example model 'sscfluids_residential_ground_source_heat_pump.slx' from the MathWorks 'Residential Ground Source Heat Pump' example:
This model plots various variables, one of these being the 'power' variable from the 'Controlled Mass Flow Rate Source (2P) ' block named 'Compressor':
The script for plotting this variable can be found in the second link in the list, 'Plot compressor power & heat transfers in system'. The power variable is obtained in the MATLAB script as follows:
pwrCompressor = simlog.Compressor.power.series.values('kW');
I was wondering how I can access the power of the compressor directly through the Simulink model, without the need for a MATLAB script.
Respuesta aceptada
MathWorks Support Team
el 31 de Mzo. de 2024 a las 0:00
Editada: MathWorks Support Team
el 29 de Mzo. de 2024
Many internal variables of Simscape blocks can be accessed through MATLAB code, but there is no direct way to access these variables from Simulink since they are not one of the block's ports. The 'power' variable in the 'Controlled Mass Flow Rate Source (2P)' is one such example. However, we can obtain the variable in Simulink with the help of sensor blocks, as explained below:
To get the value in Simulink instead of MATLAB, we will need to add a few more blocks to calculate the 'power' variable that is generated in the block.
The two types of blocks that will be added are:
What we need to do is make a system to calculate 'power = B - A' as seen below:
This generates the scope plot on the left and compared to the plot on the right generated by 'plot(t,pwrCompressor)' in the MATLAB script:
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Thermal Liquid Library en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!