Simulink Mask Port Visibility

38 visualizaciones (últimos 30 días)
Fabian David Chico Moreno
Fabian David Chico Moreno el 20 de Nov. de 2020
Respondida: Alexander el 22 de Dic. de 2023
Hello!
I have a masked simulink block which has 3 models with different level of fidelity.
I would like to add a check box that when selected turns on/off the visibility of certain ports that are/are not required in the block depending of the user selection.
I see that in some blocks such as the battery one in the figure. This functionality is already added. The port Ta is activated or deactived as a function of the check box.
Does anyone know who to do this?
Thanks in advance.

Respuestas (4)

Nikhil Sonavane
Nikhil Sonavane el 27 de Nov. de 2020
You may refer to this link for more details.

Arthur Reis
Arthur Reis el 23 de Mzo. de 2022
Perhaps using an enabled subsystem?

Katherine May
Katherine May el 20 de Abr. de 2022
If you're running a custom S-function using a MEXed C-file, you can add the checkbox value to the S-function parameters to send it through to your C file, then selectively enable only the number of ports that you need. Also make sure that accompanying TLC files & port labels will set/grab the correct values from the correct ports.
Like this:
static void mdlInitializeSizes(SimStruct *S) {
boolean usePort = mxGetScalar(ssGetSFcnParam(S, INDEX_USE_PORT)) == 1;
[...]
if(usePort){
ssSetNumInputPorts(S, 1);
ssSetNumOutputPorts(S, 1);
} else {
ssSetNumInputPorts(S, 0);
ssSetNumOutputPorts(S, 0);
}
}
I'm still investigating a solution for when the controlling block is a subsystem containing S-function blocks.

Alexander
Alexander el 22 de Dic. de 2023

Categorías

Más información sobre Author Block Masks 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!

Translated by