%Generate triangular window of length M in vector of length n, start at j=m go to
%j=m+M-1.  Preferable if M is odd. Assumes vector indexed from 0.
function y = triwindow(n, m, M)

y=zeros(1,n);
M2=floor((M-1)/2);

y(1:m)=0; y(m+M:n)=0;

y(m:m+M2) = (0:M2)/M2;
y(m+M2+1:m+M-1) = (M-M2-2:-1:0)/M2;

y = y(1:n); %Truncate to original length if expanded.