Can my S-Function have variable number of inputs and outputs?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 27 Juin 2009
Modifié(e) : Rena Berman
le 21 Juin 2018
I have a masked subsystem which contains a S-Function. I want the user to enter the desired number of input ports for the S-Function through the mask.
Réponse acceptée
MathWorks Support Team
le 15 Juin 2018
Modifié(e) : Rena Berman
le 21 Juin 2018
It is possible to have variable number of inputs and outputs for a S-Function. Please see the attached model "testsfcn.mdl". This model contains a S-Function named "testtimestwo". You need to take the number of input ports as a parameter from the S-Function and then set the number of inputs to this number. Please see the attached C-File "testtimestwo.c" which demonstrates the S-Function with variable number of inputs.
For example, you can execute the attached example by performing the following steps:
1. Download the attached MDL-file and C-file.
2. Compile the "testtimestwo.c" file using the following command
mex testtimestwo.c
3. Double-click the S-Function block in the model and enter the desired number of inputs.
You will notice that the number of inputs for the S-Function block changes to the desired number that was entered in step 3 above.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Block and Blockset Authoring dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!