Thread Subject: standalone program with changed input for Simulink.. How?

Subject: standalone program with changed input for Simulink.. How?

From: Bilal AbdulAll

Date: 14 Nov, 2009 18:17:01

Message: 1 of 5

Hi,
I've checked many threads here talking about making a standalone .exe Simulink model and evoking it from the standalone .exe program, but i couldn't find any talked about the my following issue:

My program takes input from the user and starts the Simulink Model using these inputs (inputs changes by user almost every time) then the output from the Simulink model decides wither the program continue or not!

what i know is i have to use 'rtwbuild()' to have an .exe version of the Simulink model, but the main issue here is how to send these inputs every time to the Simulink from the main standalone program and taking the output in the Main standalone program?

So, how to do that as a standalone program?

Code that starts the Simulink:

global DSSv;
options = simset('SrcWorkspace', 'parent');
sim('DSS.mdl',[], options);
DSSv.DMC = DMC(1);

thanks in advance..

Subject: standalone program with changed input for Simulink.. How?

From: Ralph Schleicher

Date: 15 Nov, 2009 13:38:07

Message: 2 of 5

"Bilal AbdulAll" <b.prodev@gmail.com> writes:

> what i know is i have to use 'rtwbuild()' to have an .exe version of
> the Simulink model, but the main issue here is how to send these
> inputs every time to the Simulink from the main standalone program and
> taking the output in the Main standalone program?

Read more about the Rsim target in the RTW manual.

> So, how to do that as a standalone program?

Do it programmatically. For example,

MATFile *f;
mxArray *rtP, *a;

f = matOpen ("default.mat", "r");
if (f == NULL)
  exit (1);

rtP = matGetArray (f, "rtP");
if (rtP == NULL)
  exit (1);

if (matClose (f) == EOF)
  exit (1);

a = mxCreateDoubleMatrix (1, 1, mxREAL);
if (a == NULL)
  exit (1);

v = mxGetPr (a);
v[0] = 2.0;

mxSetField (rtP, 1, "value", a);

f = matOpen ("param.mat", "w");
if (f == NULL)
  exit (1);

if (matPutArray (f, rtP) != 0)
  exit (1);

if (matClose (f) == EOF)
  exit (1);

/* Now call rsim executable with 'param.mat' as parameter file. */

--
Ralph Schleicher <http://ralph-schleicher.de>

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Subject: standalone program with changed input for Simulink.. How?

From: Bilal AbdulAll

Date: 15 Nov, 2009 20:05:03

Message: 3 of 5

Ralph Schleicher <rs@ralph-schleicher.de> wrote in message <87pr7j3o3k.fsf@echo.mueller-schleicher.i>...
> "Bilal AbdulAll" <b.prodev@gmail.com> writes:
>
> > what i know is i have to use 'rtwbuild()' to have an .exe version of
> > the Simulink model, but the main issue here is how to send these
> > inputs every time to the Simulink from the main standalone program and
> > taking the output in the Main standalone program?
>
> Read more about the Rsim target in the RTW manual.
>
> > So, how to do that as a standalone program?
>
> Do it programmatically. For example,
>
> MATFile *f;
> mxArray *rtP, *a;
>
> f = matOpen ("default.mat", "r");
> if (f == NULL)
> exit (1);
>
> rtP = matGetArray (f, "rtP");
> if (rtP == NULL)
> exit (1);
>
> if (matClose (f) == EOF)
> exit (1);
>
> a = mxCreateDoubleMatrix (1, 1, mxREAL);
> if (a == NULL)
> exit (1);
>
> v = mxGetPr (a);
> v[0] = 2.0;
>
> mxSetField (rtP, 1, "value", a);
>
> f = matOpen ("param.mat", "w");
> if (f == NULL)
> exit (1);
>
> if (matPutArray (f, rtP) != 0)
> exit (1);
>
> if (matClose (f) == EOF)
> exit (1);
>
> /* Now call rsim executable with 'param.mat' as parameter file. */
>
> --
> Ralph Schleicher <http://ralph-schleicher.de>
>
> Development * Consulting * Training
> Mathematical Modeling and Simulation
> Software Tools

thank you for ur effort Mr. Ralph, but actually i'm not good in C language...

here are the 'envi14.m' file that envokes 'simstart.m' file that starts the simulink ..
http://www.4shared.com/file/152744307/e72481cb/envi14.html
http://www.4shared.com/file/152744812/8200abe4/simstart.html

would u plz tell me with some details how to do it ?

thank you in advance

Subject: standalone program with changed input for Simulink.. How?

From: Ralph Schleicher

Date: 15 Nov, 2009 20:53:00

Message: 4 of 5

"Bilal AbdulAll" <b.prodev@gmail.com> writes:

> thank you for ur effort Mr. Ralph, but actually i'm not good in C language...

So it's the right time to learn it.

> here are the 'envi14.m' file that envokes 'simstart.m' file that starts the simulink ..
> http://www.4shared.com/file/152744307/e72481cb/envi14.html
> http://www.4shared.com/file/152744812/8200abe4/simstart.html
>
> would u plz tell me with some details how to do it ?

No.

--
Ralph Schleicher <http://ralph-schleicher.de>

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Subject: standalone program with changed input for Simulink.. How?

From: Bilal AbdulAll

Date: 16 Nov, 2009 04:54:02

Message: 5 of 5

Ralph Schleicher <rs@ralph-schleicher.de> wrote in message <87lji733yr.fsf@echo.mueller-schleicher.i>...
> "Bilal AbdulAll" <b.prodev@gmail.com> writes:
>
> > thank you for ur effort Mr. Ralph, but actually i'm not good in C language...
>
> So it's the right time to learn it.
>
> > here are the 'envi14.m' file that envokes 'simstart.m' file that starts the simulink ..
> > http://www.4shared.com/file/152744307/e72481cb/envi14.html
> > http://www.4shared.com/file/152744812/8200abe4/simstart.html
> >
> > would u plz tell me with some details how to do it ?
>
> No.
>
> --
> Ralph Schleicher <http://ralph-schleicher.de>
>
> Development * Consulting * Training
> Mathematical Modeling and Simulation
> Software Tools

Thank You

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
standalone simu... Bilal AbdulAll 14 Nov, 2009 13:19:05
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com