Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail
From: Ralph Schleicher <rs@ralph-schleicher.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: standalone program with changed input for Simulink.. How?
Date: Sun, 15 Nov 2009 14:38:07 +0100
Organization: Ralph Schleicher
Lines: 54
Message-ID: <87pr7j3o3k.fsf@echo.mueller-schleicher.i>
References: <hdms6t$2il$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.t-online.com 1258294142 01 n23520 tZT1pqBLi2QaNdp 091115 14:09:02
X-Complaints-To: usenet-abuse@t-online.de
X-ID: XHr5zaZTQefbMJMyo9+Rg6EcGUiLxq0mr3n7Senh16Ozm8s6beqFoQ
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:qyFapM8AH4/T6+5m/PIomnwi1go=
Xref: news.mathworks.com comp.soft-sys.matlab:585225


"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