I have a Nx3
-matrix in matlab, where I have a degree value from 0 to 360 in the first column, a radius value from 0 to 0.5 in the second and an integer in the third. Every combination out of (M(n,1),M(n,2))
is unique with M
the matrix and n
a random number between 1 and N, but it is possible that there is a value in M(:,1)
or M(:,2)
more than once. M
is sorted, first after the first row, then after the second.
My target is now to reshape this matrix into a 360xV
-matrix, with V
the amount of unique values in M(:,2)
. If there is a value in M(:,3)
at the position M(o,1)
and M(p,2)
with 1 <= o, p <= N
, it should be placed at the position (o,p)
, if there is no value, then there should a NaN
-value placed instead.
Is there a simple way to do this, or do I have to write my own function for that?
Edit:
Desired input:
0 0.25 1
0 0.43 4
1 0.25 2
2 0.03 5
2 0.43 2
Desired output:
NaN 1 4
NaN 2 NaN
5 NaN 2