# Interpolating data

## Description

Interpolation of data can be done in the LTPDA Toolbox by means of interp. This function interpolates the values in the input AO(s) at new values specified by the input parameter list.

Interp overloads interp1 function of Matlab Signal Processing Toolbox for AOs.

## Syntax

```
b = interpolate(a, pl)
```

## Parameters

The following parameters can be set in the method:

• vertices - specify the new vertices to interpolate on
• method - four methods are available for interpolating data
• 'nearest'- nearest neighbor interpolation
• 'linear' - linear interpolation
• 'spline' - spline interpolation (default option)
• 'cubic' - shape-preserving piecewise cubic interpolation
For details see interp1 help of Matlab.

## Examples

1. Interpolation of a sequence of random data at original sampling rate of 1 Hz by a factor of 10 with no initial phase.

```
% Signal generation
pl = plist('tsfcn','sin(2*pi*1.733*t)',...
'fs',1,'nsecs',10,...
'yunits','V');
x = ao(pl);
% Interpolate on a new time vector
t = linspace(0, x.data.nsecs - 1/x.data.fs, 2*len(x));
pl_spline  = plist('vertices',t);
pl_nearest = plist('vertices',t,'method','nearest');
x_spline   = interp(x,pl_spline);
x_nearest  = interp(x,pl_nearest);
iplot([x x_spline x_nearest], plist('Markers', {'x', 'o', '+'}, ...
'LineColors', {'k', 'r'}));
```