I'm trying to get my head around griddata so that I can plot an intensity as the colour on a 3D surface (a hemisphere). When I start with the example on the Mathworks website "Interpolate 3-D data set over over a grid in the x-y plane" I get the same error as I do in my own code. The code copied from the Mathworks website is as follows:
rng(0,'twister') x = 2*rand(5000,1)-1; y = 2*rand(5000,1)-1; z = 2*rand(5000,1)-1; v = x.^2 + y.^2 + z.^2;
d = -0.8:0.05:0.8; [xq,yq,zq] = meshgrid(d,d,0);
vq = griddata(x,y,z,v,xq,yq,zq); surf(xq,yq,vq); set(gca,'XTick',[-1 -0.5 0 0.5 1]); set(gca,'YTick',[-1 -0.5 0 0.5 1]);
The subsequent error is as follows:
Error using griddata (line 51) XI and YI must be the same size or vectors of different orientations.
Error in griddatatest (line 11) vq = griddata(x,y,z,v,xq,yq,zq);
I presume I have copied and pasted it correctly from Mathworks Central?! I thought it would be a good place to start for my own code...