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

Adrien Vogt-Schilb vogt at centre-cired.fr
Thu Dec 19 15:26:36 CET 2013


On 19/12/2013 15:17, Adrien Vogt-Schilb wrote:
>
> function y = map_fun(P,T,f)
>     sP = size(P, "c")
>     sT = size(T, "c")
>     P_= P'*ones(1, sT)
>     T_ = ones(sP, 1)*T
>     y = f(P_,T_)
> endfunction
>
>
> function y=somme(a,b)
>     y=a+b
> endfunction
>
> function y=power(a,b)
>     y=a.^b
> endfunction
>
> P = linspace(3,30,7)
> T = linspace(0,15,7)
>
> map_fun(P,T,somme)
>
>

Sorry, the correct vizualisation is:


["+" string(T); string(P') string(map_fun(P,T,somme))]

!+     0     2.5   5     7.5   10    12.5  15    !
!                                                !
!3     3     5.5   8     10.5  13    15.5  18    !
!                                                !
!7.5   7.5   10    12.5  15    17.5  20    22.5  !
!                                                !
!12    12    14.5  17    19.5  22    24.5  27    !
!                                                !
!16.5  16.5  19    21.5  24    26.5  29    31.5  !
!                                                !
!21    21    23.5  26    28.5  31    33.5  36    !
!                                                !
!25.5  25.5  28    30.5  33    35.5  38    40.5  !
!                                                !
!30    30    32.5  35    37.5  40    42.5  45    !


["^" string(T); string(P') string(map_fun(P,T,power))]


!^     0  2.5        5          7.5        10 12.5       15         !
! !
!3     1  15.588457  243        3787.9951  59049 920482.81  14348907   !
! !
!7.5   1  154.04697  23730.469  3655606.8  5.631D+08 8.675D+10  1.336D+13  !
! !
!12    1  498.83063  248832     1.241D+08  6.192D+10 3.089D+13  1.541D+16  !
! !
!16.5  1  1105.8847  1222981    1.352D+09  1.496D+12 1.654D+15  1.829D+18  !
! !
!21    1  2020.9159  4084101    8.254D+09  1.668D+13 3.371D+16  6.812D+19  !
! !
!25.5  1  3283.6015  10782039   3.540D+10  1.163D+14 3.817D+17  1.253D+21  !
! !
!30    1  4929.503   24300000   1.198D+11  5.905D+14 2.911D+18  1.435D+22  !


(anyway, you see the point I guess)

-- 
Adrien Vogt-Schilb
PhD Student (Cired)




More information about the users mailing list