Effacer les filtres
Effacer les filtres

How to avoid for-loop in the following code

2 vues (au cours des 30 derniers jours)
Silke
Silke le 25 Fév 2013
Hi,
I have two data sets data_1 and data_2 of size 256x256xn. One coordinate-vector thr size 1xn and one data set data_mean of size 1xn.
What I want to do is the following:
for r=1:256
for c=1:256
thr_1=interp1(data_1(r,c,:),thr,data_mean);
thr_2=interp1(data_2(r,c,:),thr,data_mean);
tb(r,c,:) = (thr-th_1)./(thr_2-thr_1);
end
end
Unfortunately I have no idea how to avoid the for-loops as the interpolation does not interpolate the data but somehow the grid.
Are there any hints how to speed this code up?
Thanks
  1 commentaire
ChristianW
ChristianW le 25 Fév 2013
Is that loop working? interp1 syntax has as first input the coordinate vector. Is thr or data_1 your coordinate vector? Can your interp1 deal with unsqueezed inputs (dim 1x1xn)? The var th_1 is unassigned, most likely a typing error. This suggests your loop never worked.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by