Path: news.mathworks.com!not-for-mail
From: "Matthew Wade" <cosmicspacepig@googlemail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Integrating compiled m-file with compiled simulink (RTW?) model
Date: Mon, 28 Jul 2008 13:11:22 +0000 (UTC)
Organization: ttz-Bremerhaven
Lines: 66
Message-ID: <g6kghq$4he$1@fred.mathworks.com>
References: <g4vq6l$8lr$1@fred.mathworks.com> <g4vr3r$m3j$1@fred.mathworks.com> <g4vsna$d95$1@fred.mathworks.com>
Reply-To: "Matthew Wade" <cosmicspacepig@googlemail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1217250682 4654 172.30.248.37 (28 Jul 2008 13:11:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 28 Jul 2008 13:11:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1052756
Xref: news.mathworks.com comp.soft-sys.matlab:482201



Let me describe the problem that I have now:

What I have done:

a). In my m-file code, I have a function that initiates all 
the states/parameters in the simulink model. These are 
taken from an Excel file, which calculates certain 
parameters for the model via a macro.

e.g. for a reactor block I have GENERAL, which is a vector 
comprising a number of states (General(1) = initial
(1)...General(n) = initial (n) ), where initial is a column 
of calculated initial states from the Excel file.

If the user selects a different option, these states will 
change in the excel file and I will get a new General 
vector.

b) I called all initial parameters to the workspace, open 
the simulink model and selected:

- Inlined Parameters - Configuration (all parameters 
selected from the initialising function (e.g. called from 
Excel file). I did not change the Storage Class.

- Rapid Simulation System Target and fixed-step solver. 
(the model runs on variable-step solver, so this may be a 
problem?)

- Build: The Simulink Model is successfully compiled

b). I used the following code on the command line:

rtP = rsimgetrtp('model','AddTunableParamInfo','on');

the rtP.parameters.map is populated with the state vectors 
(e.g. GENERAL) etc. 

saved myrtp.mat rtP

c). from the command line:

!model.exe - p myrtp.mat -s 0.1

where -s is the simulation time.

Now here are the problems:

1. The simulation time -s, should be 25 (as dictated by the 
user), if I use 25, there is a memory error message. I can 
only run the model using 0.1 or lower.

2. The output from the model (model.mat) does not 
correspond to the output I get when I run the model from 
simulink (negative numbers, unstable). 

3. in the Parameter file (rtP), I am unsure how to update 
the parameters - there is no indication where I replace, 
e.g. General(1)_0 with General(1)_1 (or General_0 with 
General_1).

I am sure I am missing a few steps here, but as I have not 
done this before, I would appreciate any ideas.

Best regards,
Matt