|
"Tom" wrote in message <in3sh0$s0c$1@fred.mathworks.com>...
> Hello all!
>
> I wan't to convert 3 vectors (a, b, c) to one matrix (A). Assume a respresent the columns of A, b the rows of A and c are the values inside A.
>
> Small example:
>
> a = [1 1 3 4]
> b = [1 4 2 3]
> c = [1.2 5.2 10.2 6.7]
>
> So the matrix A should be something like this:
>
> A = [1.2 0 0 0;
> 0 0 10.2 0;
> 0 0 0 6.7;
> 5.2 0 0 0]
>
> Another difficulty is that the values in a and b are not just integers, but they could be 1.4, 5.3, ...
>
> Is there a standard MATLAB commando for this?
>
> Thx
A = full(sparse(b,a,c))
A = accumarray([b(:) a(:)],c)
~ Jos
|