function y=trimend(x)
%TRIMEND	y=trimend(x)
%	Trim trailing zero elements in a vector.

last = max((1:length(x)) .* (x~=0));
y=x(1:last);