function P=trismooth(A,nb)

[na,nr]=size(A);
 if na==1
     A=A';
 end
 s=1/nb;
weight(1:nb+1)=[0:nb]*s;
weight(nb+1:2*nb+1)=1-[0:nb]*s;
weight=weight/sum(weight);
ii=nb:-1:1;
L(nb-ii+1)=A(1);
L(nb+1:na+nb)=A;
L(na+nb+1:na+2*nb)=A(na);

P=convn(L,weight,'valid');
 return