Mercurial > hg > ishara
view general/arrutils/defmat.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children |
line wrap: on
line source
function X=defmat(I,w,D) % defmat - specify matrix as a list of non-zero elements % % defmat :: % [[N,E]->natural] ~'N E-dim array subscripts, 1 per row', % [[N]] ~'values to place at positions specified by subs', % D:[[1,E]] ~'size of target array' % -> [[D]] ~'array of size D'. X=accumarray(I,w); if any(size(X)<D) J=num2cell(D); X(J{:})=0; end