MATLAB Answers

0

how can we calculate interpolation between two double MATLAB arrays?

Asked by Guido Pastore on 15 Mar 2019
Latest activity Commented on by Star Strider
on 15 Mar 2019
Given two arrays of double of different sizes (A = 1054x1 and B = 601x1) how is it possible to perform an interpolation ??

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Star Strider
on 15 Mar 2019
 Accepted Answer

It depends on how you want to interpolate them. The‘safest’ way is likely to interpolate the longer vector to the length of the shorter vector:
A = sin((0:1053)/105)';
B = cos((0:600)/30)';
Ai = interp1((1:numel(A))', A, (1:numel(B)), 'linear', 'extrap');
You can then see the result (a sort of Lissajous figure):
figure
plot(Ai, B)
grid

  8 Comments

Just use whatever your vectors are. The sinusoids are irrelevant.
My code would work as well with:
A = rand(1054, 1);
B = rand(601,1);
Ai = interp1((1:numel(A))', A, (1:numel(B)), 'linear', 'extrap');
or anything else your vectors have. It simply would have been more difficult graphically to demonstrate the effect.
Thank you so much for your help
As always, my pleasure.

Sign in to comment.