function [t,x,y]=Simulation(N,x0,uc,dt,covrobot,covceil,light)

%Simulation       Obtains the results of a simulations
%
% [t,x,y]=Simulation(N,x0,uc,dt,covrobot,covceil,light)
%
% N: number of simulation steps
% x0: initial state (x,y,theta)
% uc: control signals during at least the N steps
%     uc(:,:,k): control signal at time k
% covrobot: covariance of the errors associated to the control signals
% covceil: covariance of the errors of the height sensor
% light: information associated with the lighting model
%   light(1): limit
%   light(2): l2
%   light(3): l3
% t: Times of the generated simulation values
% x: states at all the steps
%   x(:,:,k): state at time step k (x,y,theta)
% y: measurements at all the steps
%   y(:,:,k): measurements at time step k (height,light)

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 8: Monte Carlo II
% Autores: Eva Besada-Portas, Sergey M. Plis


x=x0(:)';
for k=2:N
    x(:,:,k)=ModelRobot(0,x(:,:,k-1),dt,uc(:,:,k-1),covrobot);
    y(:,:,k)=ModelSensor(0,x(:,:,k),covceil,light);
end
    
t=(0:N-1)*dt;

