Interpolate Data

Interpolation is a process for estimating values that lie between known data points. It is important for applications such as signal and image processing and data visualization. MATLAB® interpolation functions let you balance the smoothness of data fit with execution speed and efficient memory use.

This example is included in the Spreadsheet Link™ EX product. To run it:

  1. Start Excel®, Spreadsheet Link EX, and MATLAB sessions.

  2. Navigate to the folder matlabroot\toolbox\exlink\.

  3. Open the file ExliSamp.xls

  4. Execute the example as needed.

This example uses a two-dimensional data-gridding interpolation function on thermodynamic data, where volume has been measured for time and temperature values. It finds the volume values underlying the two-dimensional, time-temperature function for a new set of time and temperature coordinates.

The example uses a Microsoft® Excel worksheet to organize and display the original data and the interpolated output data. You use Spreadsheet Link EX functions to copy the data to and from the MATLAB workspace, and then execute the MATLAB interpolation function. Finally, you invoke MATLAB graphics to display the interpolated data in a three-dimensional color surface.

  1. Click the Sheet3 tab on ExliSamp.xls. The worksheet for this example appears.

    The worksheet contains the measured thermodynamic data in cells A5:A29, B5:B29, and C5:C29. The time and temperature values for interpolation are in cells E7:E30 and F6:T6, respectively.

  2. Make A33 the active cell. Press F2; then press Enter to execute the Spreadsheet Link EX function that passes the Time, Temp, and Volume labels to the MATLAB workspace.

  3. Make A34 the active cell. Press F2; then press Enter to execute the Spreadsheet Link EX function that copies the original time data to the MATLAB workspace. Move to cell A35 and execute the function to copy the original temperature data. Execute the function in cell A36 to copy the original volume data.

  4. Move to cell A39 and press F2; then press Enter to copy the interpolation time values to the MATLAB workspace. Execute the function in cell A40 to copy the interpolation temperature values.

  5. Execute the function in cell A43. griddata is the MATLAB two-dimensional interpolation function that generates the interpolated volume data using the inverse distance method.

  6. Execute the functions in cells A46 and A47 to transpose the interpolated volume data and copy it to the Excel worksheet. The data fills cells F7:T30, which are enclosed in a border.

  7. Execute the function in cell A50. The MATLAB software plots and labels the interpolated data on a three-dimensional color surface, with the color proportional to the interpolated volume data.

When you finish the example, close the figure window.

Was this topic helpful?