From: A on 22 Mar 2010 14:08 > function A = assignarray(A, coords, vals); > M = accumarray(coords, vals, size(A)); > A(M~=0) = M(M~=0); > ....which would fail if zero was one of the numbers in vals... I must've taken an extra dose of stupidity pills this morning, never mind. Anyway, from Bruno's solution, using cell arrays, (reproduced below for convenience), add your own error checking if desired: function A = assignarray(A, coords, vals); c = num2cell(coords,1) A(sub2ind(size(A),c{:})) = vals;
First
|
Prev
|
Pages: 1 2 3 Prev: Hspice toolbox for MAtlab Next: error message while running engdemo in linux |