how do I restore cleared variables in Simulink simscape example?

5 visualizaciones (últimos 30 días)
I am studying the example file from Two-Phase Fluid Refrigeration of simscape .
clearing variables before running the code for the first time is fine.
but if I clear variables after running the code and run it agian, an error occurs saying that there is no information.
Are the variables created only when running for the first time?
and how do I restore cleared variables in Simulink simscape example?
Below is a video of my situation.
Thank you.
  2 comentarios
Cris LaPierre
Cris LaPierre el 13 de Nov. de 2024
Movida: Cris LaPierre el 13 de Nov. de 2024
There is a pre-load function included in the model properties. This runs when the model is opened. The simplest solution is to close the model and reopen it. Otherwise, navigate to Model Properties and copy the pre-load function code to a script and run it there.
load r134aPropertyTables
% Refrigerant:
initial_pressure = 0.6; % MPa
initial_quality = 0.05;
% Environment:
environment_temperature = 293; % K
natural_convection_coefficient = 20; % W/m^2/K
% Controller:
target_temperature = 277; % K
temperature_delta = 2; % K
% Compressor:
commanded_mass_flow = 0.004; % kg/s
controller_time_constant = 20; % s
% Expansion valve:
min_throat_area = 0.1; % mm^2
max_throat_area = 1.5; % mm^2
min_throat_temperature = 270; % K
max_throat_temperature = 250; % K
% Heat exchangers:
condenser_length = 30; % m
evaporator_length = 30; % m
fin_area = 1; % m^2
fin_convection_coefficient = 150; % W/m^2/K
% Pipes:
pipe_diameter = 0.01; % m
pipe_thickness = 0.0005; % m
% Refrigerator compartment:
interior_surface_area = 4.5; % m^2
exterior_surface_area = 6; % m^2
foam_thickness = 0.03; % m
% Material properties:
copper_density = 8940; % kg/m^3
copper_specific_heat = 390; % J/kg/K
copper_conductivity = 400; % W/m/K
foam_conductivity = 0.03; % W/m/K
You can learn more about model callbacks here: https://www.mathworks.com/help/simulink/ug/model-callbacks.html
재현
재현 el 13 de Nov. de 2024
Thank you so much for your detailed answer. I solved the problem with your help.

Iniciar sesión para comentar.

Respuesta aceptada

Angelo Yeo
Angelo Yeo el 13 de Nov. de 2024
In the shipped example, Two-Phase Fluid Refrigeration - MATLAB & Simulink - MathWorks 한국, the Simulink model has "PreLoadFcn" callback.
In order to define the variables, you can run the script in the "PreLoadFcn" callback manually, or you can open the "TwoPhaseFluidRefrigeration.slx" file to "automatically" run the PreLoadFcn callback script.
  1 comentario
재현
재현 el 13 de Nov. de 2024
Thanks for your quick reply. It took me a while to find "File Explorer", but I learned something good.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Two-Phase Fluid Library en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by