How to avoid for-loop in the following code
조회 수: 2 (최근 30일)
이전 댓글 표시
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
ChristianW
2013년 2월 25일
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!