How to use Simscape drop-down menu

5 views (last 30 days)
Jack Cimorelli
Jack Cimorelli on 1 Jul 2022
Edited: piyush on 8 Nov 2022
I am trying to implement a drop-down menu in a custom Simscape block. Other codes use "foundation.enum" as seen below: (ssc_fuel_cell)
num_ports = foundation.enum.num_ports.one; % Number of ports
% 1 - one
% 2 - two
% 3 - three
% 4 - four
However when I try:
model = foundation.enum.model.Adiabatic; % Thermodynamic model
% 1 - Adiabatic
% 0 - Isothermal
The error is:" 'foundation.enum.model.Adiabatic' is not defined in this scope. "
Any ideas on how to properly implement this?

Accepted Answer

piyush
piyush on 8 Nov 2022
Edited: piyush on 8 Nov 2022
classdef thermo_model < int32
enumeration
isothermal (0)
adiabatic (1)
end
end
save this as thermo_model.m
in the simscape component
parameters
t_m = thermo_model.isothermal; % select from dropdown list
end
use t_m with the equations
% Conditional parameter
if t_m == thermo_model.isothermal % isothermal model
equations
%
end
else
equations % t_m == thermo_model.adiabatic % adiabatic model
%
end
end

More Answers (0)

Categories

Find more on Gas Library in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!