for loop arcgridread files

1 visualización (últimos 30 días)
Kayelyn
Kayelyn el 31 de Ag. de 2023
Comentada: Mathieu NOE el 1 de Sept. de 2023
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

Respuestas (1)

Mathieu NOE
Mathieu NOE el 1 de Sept. de 2023
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 comentarios
Kayelyn
Kayelyn el 1 de Sept. de 2023
Hmm Thank you for your help.This gave me an error: Error: "Assigning the function output to this expression is not supported." I was hoping the [Z,R] output would be a structure array for each variable and each raster
Mathieu NOE
Mathieu NOE el 1 de Sept. de 2023
hello again
are you using the code with
[Z,R]=arcgridread(FileName);
or
[Z{k},R{k}]=arcgridread(FileName);

Iniciar sesión para comentar.

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by