From: Andy on
> Am I missing something? Isn't this just:
> a = b==(1:n);

No. This would require b to be the same size as 1:n.

Also, for clarity, I believe the OP switched a and b between the description and the code. At first, a was a big matrix. But since b is not otherwise described or initialized, I think we must assume b is that big matrix, and a is the temporary output of b==i for each i.
From: Jan Simon on
Dear PL,

> What I want is transforming this:
> for i=1:n
> a=(b==i);
> (operations on a)
> end
>
> into something similar like this:
> (compute a(i))
> for i=1:n
> (operations on a(i))
> end

If b is big, "(compute a(i))" will consume a lot of memory. Therefore I assume, that this will not be faster, even if you create the a(i) in a Mex.

Jan