From: Brad on
Hi all,

Does anyone know a quick way to do something like a([2,2,2])=a([2,2,2])+1; and get a(2)==3 (assuming it was initially 0) as opposed to a(2)==1.

Sorry if this is an FAQ but my search of the archive didn't come up with the answer.

Brad
From: Walter Roberson on
Brad wrote:

> Does anyone know a quick way to do something like
> a([2,2,2])=a([2,2,2])+1; and get a(2)==3 (assuming it was initially 0)
> as opposed to a(2)==1.

a = a + accumarray([2 2 2].', 1);
From: Andy on
% Did you intend to do this:

a = [2 2 2];
a=a+1
% displays: a = [3 3 3]
 | 
Pages: 1
Prev: variable size inputs/outputs
Next: DWT 3Dplot