Matlab create matrix by iterating the same command several times without for loop -
i have code this:
a = [sparse(round(rand(4,4)))]; b = [sparse(round(rand(1,4)))]; c = [bsxfun(@minus,a(1,:),b); bsxfun(@minus,a(2,:),b); bsxfun(@minus,a(3,:),b); bsxfun(@minus,a(4,:),b);]
is possible somehow define c way large amount rows (so cannot physically print command way) without loop (because loop take excessively long time)?
one options:
if prefer keep sparse matrix:
c = - repmat(b,size(a,1),1); %but slower bsxfun version.
Comments
Post a Comment