multiple interp1 without loop

Hi,
interp1 handles the following input and output: Vq = interp1(X,V,Xq)
I have X, V and Xq that each have a dimension of 12 rows by 10^5 columns.
I'd like to carry out interp1 10^5 times, treating each column of data in X,V and Xq as unique datasets in interp1, but Matlab requires that input X is a vector. So it is, therefore, not possible to do the following, because X is an array in my case:
Vq(:,1:10^5) = interp1(X,V,Xq)
I could of course do a loop:
Vq = NaN(12,10^5);
for i = 1:size(Vq,2)
Vq(:,i) = interp1(X(:,i),V(:,i),Xq(:,i))
end
That works, but it is super slow.
Does anyone know of a way to do this without implementing a loop, in a way that is significantly faster than a loop?
I realise that I may be asking the impossible here.
edit: would sub2ind help me out here?
Thanks,
Bryan

Antworten (1)

Stephen23
Stephen23 am 20 Jun. 2018

0 Stimmen

Try using a loop with interp1q.

1 Kommentar

Stephen23
Stephen23 am 21 Jun. 2018
sjohuvud's "Answer" moved here:
Thanks for the tip. Unfortunately interp1q is outdated and no longer included in my version of MatLab. As far as I can see it is the same as interp1 with linear interpolation (i.e. the default setting for interp1. It also has the same limitation of input X needing to be a vector. Do you think interp1q would be slightly faster in the loop because it is simpler?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation of 2-D Selections in 3-D Grids finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2017b

Tags

Gefragt:

am 20 Jun. 2018

Kommentiert:

am 21 Jun. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by