Imagine your 2D/3D image as a square/cube of color. What you want to do (if I understand correctly), is color each point in myData depending on where it falls into that square/cube.
However, that's not how 'CData' works in Matlab. It maps colours based on indexed location, not the actual values in the matrix. Therefore if your data is M-by-N, your colormap is M-by-N - e.g. regardless of the actual values of the data, myData(1,1)
is coloured according to myColormap(1,1)
.
In the case of the M-by-N-by-3 array, these are still just indexed locations, but the three values in each case define the colour in RGB.
It is possible to do what you want, you just have to tell Matlab directly what color in that 512 x 512 x 351 cube you want to apply to each point. Presuming you have some way of converting the x, y, z positions in myData into approximate coordinates in the 512 x 512 x 351 colorspace:
xData = myData(:,:,1);
yData = myData(:,:,2);
zData = myData(:,:,3);
% some magic here happens to make xData 1-512, yData 1-512, zData 1-351
% may require shifts, scaling, rounding as appropriate
% depends on what your myData contains exactly
% values should be integers
% now we find the positions of those points within the 512 x 512 x 351 colorspace
% size of newcmap should be 81 x 144 in your case
cind = sub2ind(size(Color),xData,yData,zData);
newcmap = Color(cind);
set(Fig.figim, 'CData', newcmap);