I need to reshape a 1-D array into a 2-D matrix. The difficulty is that there is random missing data so the RESHAPE function cannot be used in the typical fashion.
I have a set of 3 arrays: x-coordinates, y-coordinates, and a scalar.
For example, this is my input:
x = [ 1 1 1 1 1 2 2 3 3 3 ]
y = [ 1 2 3 4 5 1 2 1 2 5 ]
c = [ 2 1 2 1 2 1 2 1 2 1 ]
and this is my desired output:
x = [ 1 1 1 1 1 ; 2 2 2 2 2 ; 3 3 3 3 3 ]
y = [ 1 2 3 4 5 ; 1 2 3 4 5 ; 1 2 3 4 5 ]
c = [ 2 1 2 1 2 ; 1 2 NaN NaN NaN ; 1 2 NaN NaN 1 ]
Help is much appreciated.
Best Answer