I would like to give the name in the 'tiles' array to every loop of the AHN2 matrix. So the first loop should result in a matrix in which AHN2 = r02cn1, then the second would be called r02gz2 and so on. I don't know how to do this, any help would be
close all
clear all
tiles = {'r02cn1', 'r02gz2', 'r02hz1', 'r07dn1', 'r07dz1'};
for v = 1:length(tiles)
fileAHN2_05m = ['Geconverteerde data/ahn2/ahn2_05_ruw/' ...
char(tiles(v)), '/' char(tiles(v)), '.tif'];
[AHN2, R_AHN2] = geotiffread(fileAHN2_05m);
tiles{v} = AHN2;
end

 採用された回答

Adam
Adam 2015 年 9 月 16 日

0 投票

Make AHN2 into a struct with 'tiles' as its fields e.g.
[AHN2.( tiles{i} ), R_AHN2] = geotiffread(fileAHN2_05m);
That might not work exactly as I haven't tested the syntax in Matlab, but something like that should work, using dynamic field names on a struct.

3 件のコメント

Niek Bossers
Niek Bossers 2015 年 9 月 16 日
Alright this works, but how do I extract them from AHN2 then? I'm sorry but I'm kind of new to Matlab. Thanks for your answer!
Adam
Adam 2015 年 9 月 16 日
Just access them in the same way as e.g.:
AHN2.( tiles{3} )
or specifically as
AHN2.r02gz2
Niek Bossers
Niek Bossers 2015 年 9 月 16 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2015 年 9 月 16 日

コメント済み:

2015 年 9 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by