Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Is it possible to set up the executable generated from Simulink model to run execute some functionality only once?

1 visualizzazione (ultimi 30 giorni)
Hi,
I'm using Simulink models to generate windows executables (using Simulink Coder). I want to display some information (metadata-like info) about the model in the console at the start of execution.
I can achieve this behaviour when running the model in Simulink by adding a MATLAB function to InitFcn of the model. However, it does not work when I generate an executable from the same model. I was wondering if there is a way of adding it to model_initialise so that it runs only at the start. The only way I have been able to do so far is to include the MATLAB function in the actual Simulink model inside an enabled subsystem that is activated only for one frame. However, to me, it looks more like a hack than a proper solution.
I'm not exactly keen on manually editing the code as this would be rolled out to users who are not software engineers.
Any help would be much appreciated.
Thank you,
sunny

Risposte (1)

RahulTandon
RahulTandon il 2 Mag 2018
Bro, This attempt might not be the best.
  1. * # Write that meta-data-display like function in MATLAB code as an m file.
  2. * # convert that file into a Simulink block-Function available in MATLAB itself!
  3. * # Attach that block to the Simulink model.
  4. * # It ought to work in the start, only. No problems there, i think.
  5. * # Compile and Run.
  1 Commento
Sunny Talekar
Sunny Talekar il 9 Mag 2018
Hi Rahul,
I'm afraid I don't understand why the approach that you have suggested would only work at the start. As far as I understand, MATLAB function block would be invoked every iteration.

Community Treasure Hunt

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

Start Hunting!

Translated by