[Scilab-users] Building a f(P, T) matrix from P and T line vectors

Dang, Christophe Christophe.Dang at sidel.com
Thu Dec 19 08:59:30 CET 2013


Dear all,

I often have to work with 2-variable functions,
e.g. from equations of state involving pressure and temperature.

I have a range of P and T and build line vectors,
with linspace() or v1:p:v2.

The Kronecker product allows an easy build of P*T

P'.*.T
->
[P(1)*T(1) P(1)*T(2)
P(2)*T(1) P(2)*T(2)]

Now, I'd like to have the same thing with the sum,
without using a loop
(of course it's not the sum only,
there are adequate coefficients
and it's possibly enclosed in a exp() function or so).

A colleague of mine suggested the following way
which works well:

sP = size(P, "c");
sT = size(T, "c");

P_matrix = P'*ones(1, sT);
T_matrix = T*ones(sP, 1);

P_matrix + T_matrix
->
[P(1)+T(1) P(1)+T(2)
P(2)+T(1) P(2)+T(2)]

Now my question:

is there a more convenient way to do this,
and especially,
if I want to generate a f(P, T) matrix,
do I have to build P_matrix and T_matrix and perform

f(P_matrix, T_matrix)

or is there a way to get it directly from the P and T vectors?

-- 
Christophe Dang Ngoc Chan
Mechanical calculation engineer

Sidel Group 
Sidel Blowing & Services
CS 60627, 76059 Le Havre cedex, France
Avenue de la Patrouille de France

Tel: 33(0)2 32 85 89 32
Fax: 33(0)2 32 85 91 17

<http://www.sidel.com/>
<mailto:christophe.dang at sidel.com>

______________________________________________________________________

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
______________________________________________________________________



More information about the users mailing list