view general/arrutils/repmat_to.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
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