[scilab-Users] vectorization

grivet grivet at cnrs-orleans.fr
Tue Oct 4 14:19:51 CEST 2011


> A second way for contant step size discretisation
> dt=0.01;
> E=expm(R*dt)
> x=zeros(size(x0,'*'), size(t,'*'))
> x(:,1)=x0;
> for i=2:size(t,'*')
>   x(:,i)=E*x(:,i-1)
> end
Thank you; this is elegant and much more compact than my solution:
R = [-2,3;3,-9];
[K,S] = bdiag(R);
t = 0:0.01:3;
x0 = [1;-1];
for it = 1:size(t,"*")
    x = S*expm(K*t(it))*inv(S)*x0;
    x1(it) = x(1,1); x2(it) = x(2,1);
end






More information about the users mailing list