(* Piecewise constant signal, values intentionally skewed by exponentials to create rounding errors on sampling. *)
u[t_]:=Piecewise[{{0,t≤1},{0.1*Exp[0.01],1<t≤2},{0.7*Exp[0.02],2<t≤3},{0.3*Exp[0.005],3<t≤4},{-0.3*Exp[0.015],4<t≤5},{-0.2*Exp[0.012],5<t≤6},{0.15*Exp[0.009],6<t≤7},{0.45*Exp[0.007],7<t≤8},{0.95*Exp[0.016],8<t≤9},{-0.6*Exp[0.021],9<t≤10}}]
Plot[u[t],{t,0,10},PlotRange->{-1.5,1.5},Exclusions->None,GridLines->Automatic,GridLinesStyle->Dashed]

(* https://www.12000.org/my_notes/mma_matlab_control/KERNEL2/index.htm *)
tf:=TransferFunctionModel[(25/(2(t^2)+4t+25)),t]
yt=OutputResponse[tf,UnitStep[t],t];
tmp[x_]:=Evaluate[yt/.t->x][[1]]//N
Plot[tmp[t],{t,0,10},PlotRange->{-1.5,1.5},GridLines->Automatic,GridLinesStyle->Dashed]

(* h(x) *)
Plot[tmp'[x],{x,0,10},PlotRange->All]

whelper[0,const_]:=0
whelper[t_,const_]:=(tmp[const-(Ceiling[t]-1)]-tmp[const-t])*u[t]+whelper[Ceiling[t]-1,const]
w[t_]:=whelper[t,t]
Plot[w[x],{x,0,10},PlotRange->{-1.5,1.5},GridLines->Automatic,GridLinesStyle->Dashed]

A=Table[-tmp[0.1i-j]+tmp[0.1i-j+1],{i,1,100},{j,1,10}];

q[a_]:=1/4*(Round[4*a+1/2]-1/2)
yapprox[i_]:=q[w[i]]
y=Table[yapprox[x],{x,0.1,10,0.1}]
DiscretePlot[yapprox[x],{x,0.1,10,0.01},PlotRange->{-1.5,1.5},GridLines->Automatic,GridLinesStyle->Dashed,Joined->True,Filling->None]

yhat=PseudoInverse[A].y
reconstruction[x_]:=Piecewise[Table[{yhat[[i]],i-1<x≤i},{i,1,10}]]

(* RMS reconstruction, the original signal is red *)
g1=Plot[reconstruction[x],{x,0,10},Exclusions->None,PlotRange->{-1.5,1.5},GridLines->Automatic,GridLinesStyle->Dashed];
g2=Plot[u[x],{x,0,10},Exclusions->None,PlotStyle->{Dashed,Red},GridLines->Automatic,GridLinesStyle->Dashed];
Echo[ Sqrt[1/10*Sum[(((u[i]-yhat[[i]]))^2),{i,1,10}]],"RMS error:" ];
Show[g1,g2]

ListLinePlot[PseudoInverse[A][[2]],PlotRange->All,GridLines->{Table[i,{i,10,100,10}],Table[i,{i,0,0.1,0.02}]}]
ListLinePlot[PseudoInverse[A][[5]],PlotRange->All,GridLines->{Table[i,{i,10,100,10}],Table[i,{i,0,0.1,0.02}]}]
ListLinePlot[PseudoInverse[A][[8]],PlotRange->All,GridLines->{Table[i,{i,10,100,10}],Table[i,{i,0,0.1,0.02}]}]

(* Solutions given by means of values in intervals (i-1,i] *)
Map[Mean,Partition[y,10]];
app[x_]:=Piecewise[Table[{q[u[i]],i-1<x≤i},{i,1,10}]]
h1=Plot[app[x],{x,0,10},Exclusions->None,PlotRange->{-1.5,1.5},GridLines->Automatic,GridLinesStyle->Dashed];
Echo[Sqrt[1/10*Sum[(((u[i]-app[i]))^2),{i,1,10}]],"RMS error:" ]
Show[h1,g2]