필터 지우기
필터 지우기

resampling DEM using imresize in a for loop = cell array?

조회 수: 2 (최근 30일)
Sam
Sam 2013년 5월 2일
I have a replicated, 20 'layer' DEM datacube 2380x1707x20 and want to iteratively decrease the grid resolution of each layer, while passing all outputs into a single object. It's a scaling exercise to compare resampling with smoothing.
imresize() function works well for decreasing the grid rez, and because each for loop output contains different dims I assume passing them into a single cell array is the way to go. But my approach and/or notation is off... help?
%%RESAMPLE DEM OBJECT
rast
n = 1:1:20;
for i=1:n
out{i} = imresize(rast(:,:,i), 1/i, 'Method', 'box');
end
Cell contents assignment to a non-cell array object.

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 5월 2일
What is out before the loop starts?
You should preallocate it as a cell:
out = cell(3,1);
for ii = 1:3
out{ii} = imresize(rand(randi(100)),0.25);
end
  댓글 수: 1
Sam
Sam 2013년 5월 3일
Thanks, Sean. Another for the karma bank.
out = cell(size((rast),3),1);
for i=1:size((rast),3)
out{i} = imresize(rast(:,:,i), 1/i, 'Method', 'box');
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by