How to avoid for-loop in the following code
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
ChristianW
am 25 Feb. 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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!