Reputation: 11
I have a M-script which takes the parameter values from user via a GUI and then simulates a simulink model with the updated parameter value. I want to convert it into a standalone exe file which can run without Matlab & Simulink (i.e. only with Matlab Runtime Compiler). I'm using MATLAB 2010b 32bit.
My approach:
As the Matlab compiler cannot convert the sim function, I first converted my Simulink model to an exe-file using the Rapid Simulation target and then called the exe file from my matlab script.
[Gain1, Gain2]= InputDataGUI;
load Par.mat %contains parameter structure of the model
param_struct.parameters.values(1:2) = [Gain1 Gain2]; %update
save Par.mat param_struct;
!SimulinkModelName.exe -p Par.mat
save results.mat
This script works in Matlab without errors. Finally I packaged the M-file along with all the other required files into an exe using the deploytool. This final exe-file runs the GUI and saves the updated Par.mat file but doesn't give the simulation result file. I have also tried the To File blocks for saving results. I think the script is unable to run the simulation.
Is my approach to the problem correct?
Should I make a simulink mex file instead?
Thank you in advance for any help.
Upvotes: 1
Views: 2087
Reputation: 10782
Your general approach is correct. However, there are possibly a couple of things that you haven't done,
From File
blocks for its inputs and To File
blocks for its outputs-p
to specify parameters, -f
to specify the input file (if you want to override the one specified in the model itself), and -o
to specify the name of the output file you want the data written to (if you want to override the one specified in the model itself).Upvotes: 2