The easiest way is to use SPARSE
out = sparse(u_test(:,1),u_test(:,2),u_test(:,3));
If the target size of the array should be m-by-n
, you can write instead
out = sparse(u_test(:,1),u_test(:,2),u_test(:,3),m,n);
The good thing about using sparse is that it won't take too much space if the matrix u_test
is large. However, if for some reason you cannot use sparse, convert to a full matrix using
outNotSparse = full(out);