Contents

SVD7 Laguerre approximation

Question: see if we can fit the segment that collects charge by addding more Laguerre waveforms after the curve shape has already finish.

clear
hold off
% better a=.7

%%Generates the lagare bases
%This is done by replacing the z (FIR filter) to the laguere transfor
%functions
T=.1; a = .6; K = sqrt((1-a^2)*T);
DL=47;
%n =  numerator for the first transfer function.
%d = denominator for the first transfer function.
n = [0 K];               %find the outputs of the laguerre polynomial
d = [1 -1*a];
u = dimpulse(n,d,DL);
%n =  numerator for the first transfer function.
%d = denominator for the first transfer function.
nt = [-a 1];
dt = [1 -a];
% The next base function uses the present one as input using the FIR
% arrangement buy with Laguere TF
for i=1:10
 u = [u dlsim(nt,dt,u(:,i))];
end
Undefined function or method 'dimpulse' for input arguments of type 'double'.

Error in ==> svd7Withcomments at 19
u = dimpulse(n,d,DL); 

Load the input signal from the shapes

load shapes2
Y=shapes(:,50+1-DL:50)';
I=size(Y);
y_hat=zeros(I);

Decompose the Y input signal on the Laguere basis

and calculates the minimun square error.

invutuut=inv(u'*u)*u';  %to find the best gain on a MSE sense

for i=1:I(1,2)
    %these are the gains for each tap
  theta(:,i)=invutuut*Y(:,i);
    %this creates the waveforms back on time domain
  y_hat(:,i)=u*theta(:,i);
    %this calculates the MSE
  mse(i)=[Y(:,i)-y_hat(:,i)]'*[Y(:,i)-y_hat(:,i)];

plot(1:DL,y_hat(:,i),'g',1:DL,Y(:,i),'r')
pause(1)

end

sum(mse)
stop

%New u 'un' matrix with more samples.
un = dimpulse(n,d,140);
for i=1:20
 un = [un dlsim(nt,dt,un(:,i))];
end

for i=1:I(1,2)
  Yn(:,i)=un*theta(:,i);

%plot(1:140,Yn(:,i),'g',1:DL,Y(:,i),'r')
%pause(1)

end

invutuutn=inv(un'*un)*un';
for i=1:I(1,2)
  thetan(:,i)=invutuutn*Yn(:,i);
  yn_hat(:,i)=un*thetan(:,i);
  mse(i)=[Yn(:,i)-yn_hat(:,i)]'*[Yn(:,i)-yn_hat(:,i)];

figure(1),plot(1:140,yn_hat(:,i),'g',1:140,Yn(:,i),'r')
pause(1)

end