how do I restore cleared variables in Simulink simscape example?
2 ビュー (過去 30 日間)
古いコメントを表示
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
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
採用された回答
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Two-Phase Fluid Library についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!