Jeremy Minton About
Plotting Irregular Data Points in Matlab
Posted by Jeremy Minton, , 0 comments.

Given three vectors x, y and z containing two locations and data values, a useful interpolation function is,

function [X,Y,Z] = vect2gridData(x,y,z,n)
%Create regular grid across data space
    [X,Y] = meshgrid(linspace(min(x),max(x),n), linspace(min(y),max(y),n))
    Z = griddata(x,y,z,X,Y)

And as an example of its use,

%Generate random data
x = rand(30,1);
y = rand(30,1);
z = rand(30,1);
%Plot data
%mark original data points
hold on;scatter3(x,y,z,'o');hold off