[TRNSYS-users] Matlab calling in TRNSYS

Michaël Kummert kummert at engr.wisc.edu
Thu Dec 23 15:29:07 PST 2004


Vitte Thibaut wrote:
> Hi eveybody.
> 
> I am using 2 types 155 (calling MATLAB) on the same deck. The problem is that
> the arrays TRNSYSinputs and TRNSYSoutputs are the one from the first type in
> "component order". So the second type doesn't work because it has the wrong
> inputs.
> 
> Is it possible to define an array for each Type? Or only onen array for both
> types, but with the good dimension? 

The Matlab arrays created by Type 155 to exchange data should be sized 
using the largest number needed by all units. That way the objects are 
created and allocated only once.
So even though it appears that both units get the same trnInput array, 
they should receive different values. E.g. if the first unit has 4 
inputs and the second one has 10 inputs, the trnInputs variable will be 
a 10x1 array but the first m-file should only access elements 1-4, which 
are modified by TRNSYS when that unit is called. If you do not want to 
hard-code the number of inputs/outputs in the m-File you can use 
trnInfo(4) and trnInfo(6) to know the number of inputs and outputs that 
were set in the deck file for the current unit. This is illustrated in 
the example file for Type 155 (Examples\Data Files\Type155_CallingMatlab.m)

More generally, be careful that the m-files called by Type 155 are 
"batch m-files", not "m-functions". This means they use the global 
variable space so you have to be careful when you program them to avoid 
variable collisions.

This assumes you are using TRNSYS 16 but the logic is the same in TRNSYS 
15 (The Matlab variables were just called "inputs, outputs and info").

I hope this helps,

Michaël Kummert

-- 
_________________________________________________________

Michaël Kummert

Solar Energy Laboratory - University of Wisconsin-Madison
1303 Engr Res Bldg, 1500 Engineering Drive
Madison, WI 53706

Tel: +1 (608) 263-1589
Fax: +1 (608) 262-8464
E-mail: kummert at engr.wisc.edu

SEL Web Site: http://sel.me.wisc.edu
TRNSYS Web Site: http://sel.me.wisc.edu/trnsys



More information about the TRNSYS-users mailing list