Interp1 or its alternatives, working for matrices without loop?
Show older comments
Hi All,
I have matrices X and Y, with size(x) = [30,30000], and size(y) = [30,30000]. Columnar data in x are different between different columns, and so is y. xi is interpolation vector, with size(xi) = [60, 1]. For linear interpolation, I know I can do:
for i=1: 30000
output(:,i) = interp1(x(:,i), y(:,i), xi);
end
But it is slow to go through the 30000 loops. What is worse, x and y are daily data, and I need to do it annually. Therefore, using loop is a way too slow. I found that shared scripts like ScaleTime exists, which however do not accept x with different columnar values.
Question 1:
Is there a vecterize method to do the interpolation (linear)?
Question 2:
What about vecterized interpolation using cubic or pchip?
Many thanks,
John
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!