<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200</link>
    <title>MATLAB Central Newsreader - Integrating compiled m-file with compiled simulink (RTW?) model</title>
    <description>Feed for thread: Integrating compiled m-file with compiled simulink (RTW?) model</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 08 Jul 2008 13:31:01 -0400</pubDate>
      <title>Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#441800</link>
      <author>Matthew Wade</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I have a series of Matlab GUIs with different &lt;br&gt;
functionalities (database, visualisation, excel data &lt;br&gt;
transfer). All of these compile straightforwardly with the &lt;br&gt;
Matlab Compiler 4.3.&lt;br&gt;
&lt;br&gt;
In one of the GUIs I have a button that initiates the &lt;br&gt;
simulation of a simulink model and as &lt;br&gt;
functions 'sim', 'simset' etc, cannot be compiled in &lt;br&gt;
matlab, I have turned to Real Time Workshop. &lt;br&gt;
&lt;br&gt;
However, before I begin to understand how to create stand-&lt;br&gt;
alone applications of simulink models via RTW, I would like &lt;br&gt;
to know if there is a way to integrate the command to run &lt;br&gt;
this model into the compiled GUI executable.&lt;br&gt;
&lt;br&gt;
i.e. the code [T,X,Y]=sim('mymodel'...)&lt;br&gt;
&lt;br&gt;
will not compile using mcc. &lt;br&gt;
&lt;br&gt;
If I  manage to get a stand-alone application &lt;br&gt;
for 'mymodel'...how do I replace the above code into the m-&lt;br&gt;
file/executable.&lt;br&gt;
&lt;br&gt;
Best regards,&lt;br&gt;
&lt;br&gt;
Matt</description>
    </item>
    <item>
      <pubDate>Tue, 08 Jul 2008 13:46:35 -0400</pubDate>
      <title>Re: Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#441805</link>
      <author>Titus</author>
      <description>&lt;br&gt;
&quot;Matthew Wade&quot; &amp;lt;cosmicspacepig@googlemail.com&amp;gt; schrieb im Newsbeitrag &lt;br&gt;
news:g4vq6l$8lr$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have a series of Matlab GUIs with different&lt;br&gt;
&amp;gt; functionalities (database, visualisation, excel data&lt;br&gt;
&amp;gt; transfer). All of these compile straightforwardly with the&lt;br&gt;
&amp;gt; Matlab Compiler 4.3.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; In one of the GUIs I have a button that initiates the&lt;br&gt;
&amp;gt; simulation of a simulink model and as&lt;br&gt;
&amp;gt; functions 'sim', 'simset' etc, cannot be compiled in&lt;br&gt;
&amp;gt; matlab, I have turned to Real Time Workshop.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; However, before I begin to understand how to create stand-&lt;br&gt;
&amp;gt; alone applications of simulink models via RTW, I would like&lt;br&gt;
&amp;gt; to know if there is a way to integrate the command to run&lt;br&gt;
&amp;gt; this model into the compiled GUI executable.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; i.e. the code [T,X,Y]=sim('mymodel'...)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; will not compile using mcc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; If I  manage to get a stand-alone application&lt;br&gt;
&amp;gt; for 'mymodel'...how do I replace the above code into the m-&lt;br&gt;
&amp;gt; file/executable.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Best regards,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Matt&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
Hi Matt,&lt;br&gt;
you will need to use the Rapid-Simulation target for the Real-Time Workshop &lt;br&gt;
compilation. Take a look at the function rsimgetrtp for collecting the &lt;br&gt;
parameters, and esp. the option &quot;AddTunableParamInfo&quot; . This function itself &lt;br&gt;
is not compilable, but once you have the parameter structure, you can update &lt;br&gt;
it from your code.&lt;br&gt;
&lt;br&gt;
The code will be replaced by something like&lt;br&gt;
&lt;br&gt;
paramStruct = load('paramfile.mat');&lt;br&gt;
paramStruct.parameters.paramA = 42;&lt;br&gt;
save paramfile paramStruct&lt;br&gt;
system('theCompiledModel.exe -p paramfilein=paramfile');&lt;br&gt;
result = load('output.mat');&lt;br&gt;
plot(result.rt_tout, result.rt_yout)&lt;br&gt;
&lt;br&gt;
There are some demos under Real-Time Workshop-&amp;gt;Accelerated Simulations which &lt;br&gt;
should give additional help.&lt;br&gt;
&lt;br&gt;
Titus </description>
    </item>
    <item>
      <pubDate>Tue, 08 Jul 2008 14:14:02 -0400</pubDate>
      <title>Re: Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#441812</link>
      <author>Matthew Wade</author>
      <description>&quot;Titus&quot; &amp;lt;titus.edelhofer@mathworks.de&amp;gt; wrote in message &amp;gt; &lt;br&gt;
Hi Matt,&lt;br&gt;
&amp;gt; you will need to use the Rapid-Simulation target for the &lt;br&gt;
Real-Time Workshop &lt;br&gt;
&amp;gt; compilation. Take a look at the function rsimgetrtp for &lt;br&gt;
collecting the &lt;br&gt;
&amp;gt; parameters, and esp. the option &quot;AddTunableParamInfo&quot; . &lt;br&gt;
This function itself &lt;br&gt;
&amp;gt; is not compilable, but once you have the parameter &lt;br&gt;
structure, you can update &lt;br&gt;
&amp;gt; it from your code.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The code will be replaced by something like&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; paramStruct = load('paramfile.mat');&lt;br&gt;
&amp;gt; paramStruct.parameters.paramA = 42;&lt;br&gt;
&amp;gt; save paramfile paramStruct&lt;br&gt;
&amp;gt; system('theCompiledModel.exe -p paramfilein=paramfile');&lt;br&gt;
&amp;gt; result = load('output.mat');&lt;br&gt;
&amp;gt; plot(result.rt_tout, result.rt_yout)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; There are some demos under Real-Time Workshop-&lt;br&gt;
&amp;gt;Accelerated Simulations which &lt;br&gt;
&amp;gt; should give additional help.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Titus &lt;br&gt;
&amp;gt; &lt;br&gt;
Thanks Titus,&lt;br&gt;
&lt;br&gt;
At least I now know it can be done. But I first must learn &lt;br&gt;
RTW before getting to that stage.&lt;br&gt;
&lt;br&gt;
Best regards&lt;br&gt;
Matt</description>
    </item>
    <item>
      <pubDate>Mon, 28 Jul 2008 13:11:22 -0400</pubDate>
      <title>Re: Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#445847</link>
      <author>Matthew Wade</author>
      <description>Let me describe the problem that I have now:&lt;br&gt;
&lt;br&gt;
What I have done:&lt;br&gt;
&lt;br&gt;
a). In my m-file code, I have a function that initiates all &lt;br&gt;
the states/parameters in the simulink model. These are &lt;br&gt;
taken from an Excel file, which calculates certain &lt;br&gt;
parameters for the model via a macro.&lt;br&gt;
&lt;br&gt;
e.g. for a reactor block I have GENERAL, which is a vector &lt;br&gt;
comprising a number of states (General(1) = initial&lt;br&gt;
(1)...General(n) = initial (n) ), where initial is a column &lt;br&gt;
of calculated initial states from the Excel file.&lt;br&gt;
&lt;br&gt;
If the user selects a different option, these states will &lt;br&gt;
change in the excel file and I will get a new General &lt;br&gt;
vector.&lt;br&gt;
&lt;br&gt;
b) I called all initial parameters to the workspace, open &lt;br&gt;
the simulink model and selected:&lt;br&gt;
&lt;br&gt;
- Inlined Parameters - Configuration (all parameters &lt;br&gt;
selected from the initialising function (e.g. called from &lt;br&gt;
Excel file). I did not change the Storage Class.&lt;br&gt;
&lt;br&gt;
- Rapid Simulation System Target and fixed-step solver. &lt;br&gt;
(the model runs on variable-step solver, so this may be a &lt;br&gt;
problem?)&lt;br&gt;
&lt;br&gt;
- Build: The Simulink Model is successfully compiled&lt;br&gt;
&lt;br&gt;
b). I used the following code on the command line:&lt;br&gt;
&lt;br&gt;
rtP = rsimgetrtp('model','AddTunableParamInfo','on');&lt;br&gt;
&lt;br&gt;
the rtP.parameters.map is populated with the state vectors &lt;br&gt;
(e.g. GENERAL) etc. &lt;br&gt;
&lt;br&gt;
saved myrtp.mat rtP&lt;br&gt;
&lt;br&gt;
c). from the command line:&lt;br&gt;
&lt;br&gt;
!model.exe - p myrtp.mat -s 0.1&lt;br&gt;
&lt;br&gt;
where -s is the simulation time.&lt;br&gt;
&lt;br&gt;
Now here are the problems:&lt;br&gt;
&lt;br&gt;
1. The simulation time -s, should be 25 (as dictated by the &lt;br&gt;
user), if I use 25, there is a memory error message. I can &lt;br&gt;
only run the model using 0.1 or lower.&lt;br&gt;
&lt;br&gt;
2. The output from the model (model.mat) does not &lt;br&gt;
correspond to the output I get when I run the model from &lt;br&gt;
simulink (negative numbers, unstable). &lt;br&gt;
&lt;br&gt;
3. in the Parameter file (rtP), I am unsure how to update &lt;br&gt;
the parameters - there is no indication where I replace, &lt;br&gt;
e.g. General(1)_0 with General(1)_1 (or General_0 with &lt;br&gt;
General_1).&lt;br&gt;
&lt;br&gt;
I am sure I am missing a few steps here, but as I have not &lt;br&gt;
done this before, I would appreciate any ideas.&lt;br&gt;
&lt;br&gt;
Best regards,&lt;br&gt;
Matt</description>
    </item>
    <item>
      <pubDate>Mon, 28 Jul 2008 13:17:04 -0400</pubDate>
      <title>Re: Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#445849</link>
      <author>Titus</author>
      <description>&lt;br&gt;
&quot;Matthew Wade&quot; &amp;lt;cosmicspacepig@googlemail.com&amp;gt; schrieb im Newsbeitrag &lt;br&gt;
news:g6kghq$4he$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Let me describe the problem that I have now:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; What I have done:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; a). In my m-file code, I have a function that initiates all&lt;br&gt;
&amp;gt; the states/parameters in the simulink model. These are&lt;br&gt;
&amp;gt; taken from an Excel file, which calculates certain&lt;br&gt;
&amp;gt; parameters for the model via a macro.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; e.g. for a reactor block I have GENERAL, which is a vector&lt;br&gt;
&amp;gt; comprising a number of states (General(1) = initial&lt;br&gt;
&amp;gt; (1)...General(n) = initial (n) ), where initial is a column&lt;br&gt;
&amp;gt; of calculated initial states from the Excel file.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; If the user selects a different option, these states will&lt;br&gt;
&amp;gt; change in the excel file and I will get a new General&lt;br&gt;
&amp;gt; vector.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; b) I called all initial parameters to the workspace, open&lt;br&gt;
&amp;gt; the simulink model and selected:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; - Inlined Parameters - Configuration (all parameters&lt;br&gt;
&amp;gt; selected from the initialising function (e.g. called from&lt;br&gt;
&amp;gt; Excel file). I did not change the Storage Class.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; - Rapid Simulation System Target and fixed-step solver.&lt;br&gt;
&amp;gt; (the model runs on variable-step solver, so this may be a&lt;br&gt;
&amp;gt; problem?)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; - Build: The Simulink Model is successfully compiled&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; b). I used the following code on the command line:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; rtP = rsimgetrtp('model','AddTunableParamInfo','on');&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; the rtP.parameters.map is populated with the state vectors&lt;br&gt;
&amp;gt; (e.g. GENERAL) etc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; saved myrtp.mat rtP&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; c). from the command line:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; !model.exe - p myrtp.mat -s 0.1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; where -s is the simulation time.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Now here are the problems:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 1. The simulation time -s, should be 25 (as dictated by the&lt;br&gt;
&amp;gt; user), if I use 25, there is a memory error message. I can&lt;br&gt;
&amp;gt; only run the model using 0.1 or lower.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 2. The output from the model (model.mat) does not&lt;br&gt;
&amp;gt; correspond to the output I get when I run the model from&lt;br&gt;
&amp;gt; simulink (negative numbers, unstable).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 3. in the Parameter file (rtP), I am unsure how to update&lt;br&gt;
&amp;gt; the parameters - there is no indication where I replace,&lt;br&gt;
&amp;gt; e.g. General(1)_0 with General(1)_1 (or General_0 with&lt;br&gt;
&amp;gt; General_1).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I am sure I am missing a few steps here, but as I have not&lt;br&gt;
&amp;gt; done this before, I would appreciate any ideas.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Best regards,&lt;br&gt;
&amp;gt; Matt&lt;br&gt;
&lt;br&gt;
Hi Matt,&lt;br&gt;
&lt;br&gt;
w.r.t. 2): this might correspond to you using the fixed step solver for the &lt;br&gt;
compiled application and the variable step solver (with e.g. Zero-Crossing &lt;br&gt;
detection) in the Simulink program. Try to use the fixed step solver in &lt;br&gt;
Simulink and see, if you get the same results/problems.&lt;br&gt;
&lt;br&gt;
Titus </description>
    </item>
    <item>
      <pubDate>Mon, 28 Jul 2008 13:36:01 -0400</pubDate>
      <title>Re: Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#445852</link>
      <author>Matthew Wade</author>
      <description>Hi Titus,&lt;br&gt;
&lt;br&gt;
The model will not run with a fixed-step solver from &lt;br&gt;
Simulink, I have to use Variable-step.&lt;br&gt;
&lt;br&gt;
I have noticed -S option to allow specification of Solver &lt;br&gt;
type, parameters. Maybe this will work.&lt;br&gt;
&lt;br&gt;
Cheers&lt;br&gt;
Matt&lt;br&gt;
&lt;br&gt;
&amp;gt; Hi Matt,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; w.r.t. 2): this might correspond to you using the fixed &lt;br&gt;
step solver for the &lt;br&gt;
&amp;gt; compiled application and the variable step solver (with &lt;br&gt;
e.g. Zero-Crossing &lt;br&gt;
&amp;gt; detection) in the Simulink program. Try to use the fixed &lt;br&gt;
step solver in &lt;br&gt;
&amp;gt; Simulink and see, if you get the same results/problems.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Titus &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Mon, 28 Jul 2008 14:37:02 -0400</pubDate>
      <title>Re: Integrating compiled m-file with compiled simulink (RTW?) model</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172200#445865</link>
      <author>Matthew Wade</author>
      <description>the -S option with a solveroptions.mat file does not seem &lt;br&gt;
to do anything, even when I save solveroptions.mat with &lt;br&gt;
nonsense parameters (e.g. solver 'null'). Running the &lt;br&gt;
executable does not seem to take these options into &lt;br&gt;
consideration - the output is still the same.&lt;br&gt;
&lt;br&gt;
&quot;Matthew Wade&quot; &amp;lt;cosmicspacepig@googlemail.com&amp;gt; wrote in &lt;br&gt;
message &amp;lt;g6ki01$mle$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Titus,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The model will not run with a fixed-step solver from &lt;br&gt;
&amp;gt; Simulink, I have to use Variable-step.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have noticed -S option to allow specification of Solver &lt;br&gt;
&amp;gt; type, parameters. Maybe this will work.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Cheers&lt;br&gt;
&amp;gt; Matt&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Hi Matt,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; w.r.t. 2): this might correspond to you using the fixed &lt;br&gt;
&amp;gt; step solver for the &lt;br&gt;
&amp;gt; &amp;gt; compiled application and the variable step solver (with &lt;br&gt;
&amp;gt; e.g. Zero-Crossing &lt;br&gt;
&amp;gt; &amp;gt; detection) in the Simulink program. Try to use the &lt;br&gt;
fixed &lt;br&gt;
&amp;gt; step solver in &lt;br&gt;
&amp;gt; &amp;gt; Simulink and see, if you get the same results/problems.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Titus &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; </description>
    </item>
  </channel>
</rss>

