Error with s-function when simulink system is called within a matlab function

1 vue (au cours des 30 derniers jours)
jpro89
jpro89 le 13 Déc 2018
Modifié(e) : Fangjun Jiang le 13 Déc 2018
I face a problem regarding the simulation of a Simulink file. In my main file I am calling a function and within this function I am using the sim command
sim('Simulink_file_name', 'SrcWorkspace', 'current');
to run the simulation. For the simulink to have access in the caller workspace, I have to use the SrcWorkspace argument. However, the simulink file seems to be unable to read the s-functions which are needed. The error that I get is the following.
Error using 'Simulink_file_name'. Error in 'Block_name' while executing C MEX S-function 'S-function name', (mdlStart), at time 0.0. Caused by:
Error using Simulink_file_name
Could not get the variable 1.
Of course, when I try to simulate the system in my main loop instead of a function, everything works properly.
Has anybody experienced a similar problem or knows how I can circumvent it?

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 13 Déc 2018
Modifié(e) : Fangjun Jiang le 13 Déc 2018
You need to specify the srcworkspace as 'Parent'.

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by