Rajeevx5
Rajeevx5

Reputation: 37

How to create a Simulink executable which uses .mat file input

I have created a gas turbine model on simulink for my final year project for my engineering degree. However I need some help in converting it to a standalone executable, currently the standalone executable uses the inputs that were there when it was compiled. How do I compile an executable which requires a .mat file input? Regards Rajeev

Upvotes: 0

Views: 892

Answers (1)

ToBe
ToBe

Reputation: 971

  1. Generate C-Code from your existing simulink model by using an additional toolbox: Simulink Coder.
  2. To read from (or write to) Mat-File you can use C-API to Mat-File. You will find the sources in: "your Matlab - Installation - Folder"/extern/examples/eng_mat
  3. In the generated c-Code you will find a structure representing the inports of your model. Write the corresponding value you read from the matfile to in port. You will probably need a loop of call for MdlInputs, MdlUpdate, MdlOutputs (implementation of these 3 functions are also generated ) to run the simulation. A good starting example is the *main.c of the grt-Target ("your Matlab - Installation - Folder"/rtw/c/grt).

Upvotes: 1

Related Questions