Azzera filtri
Azzera filtri

Interpolating data in 1D with 2D sample points and a 2D matrix

12 visualizzazioni (ultimi 30 giorni)
I have a matrix of Temperatures ( T - [120xN] ) at different heights ( H - [120xN] ). I want to obtain the Temperatures at a set vector of heights ( Hnew - [100x1] ], where N is the total number of lines I want to independently interpolate in 1D.
I can solve this with a loop quite easily
Tnew = zeros(length(Hnew),N);
for i-1:N
Tnew(:,i) = interp1(H(:,i),T(:,i),Hnew);
end
But since I have many iterations to perform (N ~ 2 million), I am looking for a solution without a loop.
What is the optimum way to do this?

Risposta accettata

Vijay
Vijay il 30 Dic 2022
The use of loop does not create any performance disadvantage. The bottleneck is the interpolation part. If your computer has large number of cores, >4, then you can utilize parfor pragma to parallelize your loop.
Tnew = zeros(length(Hnew),N);
parfor
for i-1:N
Tnew(:,i) = interp1(H(:,i),T(:,i),Hnew);
end
Please use the link below for more information
Hope that helps

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by