Borrar filtros
Borrar filtros

How to avoid for-loop in the following code

2 visualizaciones (últimos 30 días)
Silke
Silke el 25 de Feb. de 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 comentario
ChristianW
ChristianW el 25 de Feb. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by