With ?MatLab, Steps to Graph in 3-D with Irregular Data

  1. Create column vectors x, y, and z containing the data to be plotted.

  2. Create two grids that the irregular data can be placed on, using the function linspace (beginning, end, n points evenly spaced between beginning and end). These two grids should be called XI and YI, and a sample piece of code is: XI = linspace(5, 90, 10). The sample piece gives a vector containing 10 evenly spaced points from 5 to 90.

  3. Put the two grids together with the following code: [XI, YI] = meshgrid(XI, YI).

  4. Create another variable ZI that takes the irregular data and fits a form z = f(x,y) to it. The code is: ZI = griddata(x, y, z, XI, YI).

  5. Plot using mesh(XI, YI, ZI), meshc(XI, YI, ZI), contourf(XI, YI, ZI), or any other 3-D plot needed.