view general/arrutils/interleave.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 03694e5c8365
children
line wrap: on
line source
% interleave - interleave elements of an array
%
% interleave :: [[1,N]], [[1,M]] -> [[1,N+M]].
%
% interleave(A,B) interleaves the elements of A and B until there are
% no elements left in one of them. The remaining elements of the other
% are then appending. 
function z=interleave(x,y)

x=x(:);
y=y(:);

nx=length(x);
ny=length(y);

if nx>ny
	z(1:2:2*ny-1)=x(1:ny);
	z(2:2:2*ny)=y;
	z(2*ny+1:nx+ny)=x(ny+1:end);
else
	z(1:2:2*nx-1)=x;
	z(2:2:2*nx)=y(1:nx);
	z(2*nx+1:nx+ny)=y(nx+1:end);
end