how do I restore cleared variables in Simulink simscape example?

조회 수: 2 (최근 30일)
재현
재현 2024년 11월 13일
댓글: 재현 2024년 11월 13일
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
Cris LaPierre
Cris LaPierre 2024년 11월 13일
이동: Cris LaPierre 2024년 11월 13일
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
재현
재현 2024년 11월 13일
Thank you so much for your detailed answer. I solved the problem with your help.

댓글을 달려면 로그인하십시오.

채택된 답변

Angelo Yeo
Angelo Yeo 2024년 11월 13일
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
재현
재현 2024년 11월 13일
Thanks for your quick reply. It took me a while to find "File Explorer", but I learned something good.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Two-Phase Fluid Library에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by