x=[0.1 0.3 0.5 -0.1 -0.2 0.1 0.2 0.3 0.5 0.2];
u=zeros(100,1);
for i=1:10
    for j=1:10
        u(10*(i-1)+j)=x(i);
    end
end
fun = @(x) exp(-(x.^2));
A=zeros(100,10);
for k=1:100
    for j=1:10
        fun = @(x) exp(-((0.1)*k-x).^2);
        A(k,j)=integral(fun,j-1,j);
    end
end
y=A*x';
y= (0.25)*(round(4*y+0.5)-0.5); %quantización.
t=0:0.1:9.9;
plot(t,y,'red');
hold on
plot(t,u,'blue');
% y=Ax+v donde v es el error de quantización.
xls=A\y;
uls=zeros(100,1);
for i=1:10
    for j=1:10
        uls(10*(i-1)+j)=xls(i);
    end
end
plot(t,uls,'green');
hold off
ecm=norm(x'-xls)*(1/sqrt(10));