%% Interpolate Rows of Data
% Generate three separate data sets of normally distributed random numbers. Assume the data is sampled at the positive integers, 1:N. Store the data sets as rows in a matrix.

A = randn(3,20);
x = 1:20;

%
% Interpolate the rows of the matrix at 500 query points each. Specify dim = 2 so that interpft works on the rows of A.

N = 500;
y = interpft(A,N,2);

%
% Calculate the spacing interval of the interpolated data dy. Truncate the data in y to match the sampling density of x2.

dy = length(x)/N;
x2 = 1:dy:20;
y = y(:,1:length(x2));

%
% Plot the results.

subplot(3,1,1)
plot(x,A(1,:)','o');
hold on
plot(x2,y(1,:)','--')
title('Row 1')

subplot(3,1,2)
plot(x,A(2,:)','o');
hold on
plot(x2,y(2,:)','--')
title('Row 2')

subplot(3,1,3)
plot(x,A(3,:)','o');
hold on
plot(x2,y(3,:)','--')
title('Row 3')

% Copyright 2012 The MathWorks, Inc.