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

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents e44f49929e56
children
line wrap: on
line source
function b=repmat_to(a,sz)
% repmat_to(a,sz): Like repmat, but sz is TARGET size, not repliction count
%
% repmat_to :: [[Size1]->A], Size2:dim -> [[Size2]->A].

% this will barf if any dimension of a is zero.
	if any(sz==0)
		b=zeros(sz);
	else
		sa=size1(a);
		l=length(sz)-length(sa);
		b=repmat(a,tosize(sz./[sa ones(1,l)]));
	end