Passing workspace variables to Simulink models running in external mode

2 vues (au cours des 30 derniers jours)
Fab le 3 Avr 2015
Commenté : Cyril Kincel le 15 Mai 2020
Hi all,
I have a problem involving sharing workspace variables with a Simulink model running in external mode, executed from a Matlab script (i.e. a function of the type function[]=run_mdl(…,…,…)).
The goal is to measure variables from a human experiment, that logs into a .mat file, and to use the measured data to playback in a subsequent simulink model, that has to run in external mode. The variables are matrices that contain up to 120k rows. This is unfortunate, because I know that I can pass variables as constants by using the following:
But if I try to do this in such large variables, it takes so long to pass big strings.
I tried a few approaches so far, none of which is completely satisfying:
1) Including the "From File" block in the library browser, loading the appropriate .mat file and processing the required columns. This is unsatisfactory because when the model runs in external mode it requires recompilation of the model to pass the correct .mat file (otherwise, it keeps the values of the .mat file at compilation; I discovered after some careful testing). I can script a rtwbuild command to avoid this problem, but this takes too long for what we would like, and I am bothered by the fact that I don't think that recompilation should be needed since I can pass to the simulink model a vector with pre-defined dimensions.
2) I tried using the "From Workspace" block in the library browser, but I did not find a way to instruct the simulink model to use the "current" workspace since I am running the model in external mode. I found this solution (<>, which looked great, but the "sim" function does not work in external mode. I looked at possible arguments for set_param, to say something like set_param(ModelName,'SrcWorkspace','current'), but this does not seem to be an option.
Does anyone have suggestions on how to solve this problem?

Réponses (1)

Fab le 20 Avr 2015
No one has a clue?


En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by