clear all
clc
 
for k=1:3
A=[1,.1,.2;.3,1,.1;.2,.1,1];
B=[1,.5,.2;.5,1,.1];
tau=[.1,0,0;0,.1,0;0,0,.1];
 
x0=random('normal',3,1,3,1);
 
n1=10;

for i=1:n1
    u1=random('normal',0,1,3,1);
    x=x0;
    x=A*x0 + tau*u1;
    u2 = random('normal',0,0.2,2,1);
    y=B*x + u2;
    
    for j=1:3;
       X1(i,j)=x(j); 
    end
 
    for j=1:2;
       Y1(i,j)=y(j); 
    end
    x0=x; 
end;
 
for i=1:n1
    normx1(i)=norm(X1(i,:)-X1(1,:));
    normy1(i)=norm(Y1(i,:)-Y1(1,:));
end;
 
figure(1)
plot(normx1);
title(['||X(t) - X(1)|| versus time for simulation ' int2str(k)]);
saveas(figure(1),['Simulated process- ' int2str(k) ' of x prob 1.png']);
 
figure(2)
plot(normy1);
title(['||Y(t) - Y(1)|| versus time for simulation ' int2str(k)']);
saveas(figure(2),['Simulated process- ' int2str(k) ' of y prob 1.png']);
 
end
