interp

From DavinciWiki
Jump to: navigation, search


Description

Point interpolation algorithm which can be used to resample data to a new set of x values using either linear or cubic spline interpolation.

NOTE: The X value must be monotonically increasing. Or more simply, the next number must be larger than the previous number.

Arguments and Return Values

Arguments: An X and Y numerical array pair and a new X numerical array.

Return Value: A numerical array of Y values which is resampled to the new X numerical array

Usage

Syntax: interp(object = VAL, from = VAL, to = VAL [,type = STRING] [,ignore = VAL] )

object   - a set of Y values that correspond to the original or from X values
from     - a set of X values that correspond to the object Y values
to       - the new set of X values which will be the resampling source data
type     - the type of interpolation ("linear" (default) and "cubic" are the only two options)
ignore   - ignore value 

Examples

dv> original
struct, 2 elements
   data: 1x1x1000 array of float, bsq format [4,000 bytes]
   xaxis: 1x1x1000 array of float, bsq format [4,000 bytes]

dv> new_xaxis
1x1x50 array of float, bsq format [200 bytes]

dv> interpolated_data = interp(original.data, original.xaxis, new_xaxis) 
1x1x50 array of float, bsq format [200 bytes]

dv> interpolated_data = interp(original.data, original.xaxis, new_xaxis, type = "cubic") 
1x1x50 array of float, bsq format [200 bytes]


FAILURE:

 dv> interp(4//8//12//16//20//24,2.//4.//7.//9.//12.//16.,3.)
 6.000000000
 dv> interp(4//8//12//16//20//24,-2.//-4.//-7.//-9.//-12.//-16.,-3.)
 11.00000000

The second answer should also be 6.

This function also only works on single data points; trying to use it to interpolate 2d arrays of data will fail.

Images

interp.png

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Core Changes

Modified On: 07-23-2012

Personal tools