%%%% Square matrix summation - works OK 23.05..2014
clear;clc;clf reset;warning off MATLAB:divideByZero;close all
sitil = ['-k  ';'--k ';':k  ';'-.k ';'--ok';':ok ';'-k  ';'--k ';':k  '];linwid = [2 3 3 2 2 2 1 2 2];
t = -4:0.1:4;
xt = 1./(1 + (2*t).^2);%xt = 1./(1 + t.^4);
plot(t, xt,sitil(1,:),'LineWidth',linwid(2));
set(gcf,'Color',[1 1 1]);set(gca,'FontSize',16);axis off
Narr = [1 2 3 4];N = Narr(3);ta = 0.5;
Xmat = [];
for m = -N:N
    xr = [];
    for n = -N:N
       t = m + n*ta;
       %xt = 1/(1 + t^4);
       xt = 1./(1 + (2*t).^2);
       xr = [xr xt];
    end
    Xmat = [Xmat;xr];
end
Xmat
cn = inv(Xmat)*[zeros(N,1); 1; zeros(N,1)]
t = -2:0.5:2;t = -1.5:0.5:1.5;%t = -1:0.5:1;%t = -0.5:0.5:0.5;
xt = 1./(1 + (2*t).^2);%xt = 1./(1 + t.^4);
xteq = sum(xt);ttum = -4:0.5:4;xttum = sum(1./(1 + (2*ttum).^2));R = xteq/xttum
q0 = cn'*xt';