for loop arcgridread files

조회 수: 4 (최근 30일)
Kayelyn
Kayelyn . 2023년 8월 31일
댓글: Mathieu NOE . 2023년 9월 1일
Hello, I have several digital elevation rasters saved as *.asc files in a folder. I am using arcgridread and I would like to create a function that would read each file in with the appropriate Z,R parameters.
Example Code
all_dems=dir('filnename')
for i=length(a)
baseFileName=as(K).name;
fprintf(1,'Now reading %s\n',fullFileName);
[Z,R]=arcgridread(fullFileName);
end

답변 (1개)

Mathieu NOE
Mathieu NOE 2023년 9월 1일
hello
try this
I didn't index Z and R with k, as I suspect you want to use it right after (inside the for loop)
otherwise you may want to index it like
[Z{k},R{k}]=arcgridread(FileName);
d = dir('*.asc'); % d is a structure array
for k = 1:numel(d)
FileName=d(k).name;
fprintf(1,'Now reading %s\n',FileName);
[Z,R]=arcgridread(FileName);
% your code
end
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2023년 9월 1일
hello again
are you using the code with
[Z,R]=arcgridread(FileName);
or
[Z{k},R{k}]=arcgridread(FileName);

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

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by