How can a particular .tif file be read from a folder which is having 10 files with different suffix like 'file_1', 'file_2'...?I only want to read file_2.tif and file_4.tif.
8 ビュー (過去 30 日間)
古いコメントを表示
I have used the following code
folder='D\Project';
file2=(dir(fullfile(folder,'*_2.tif)));
This code is returning a structure where the name can be read only. I want the content of the file, as it should have several rows and columns.
How can I use the geotiffread function with it to read the content of the file?
I am stuck in here. I t will be helpful if someone can assist.
0 件のコメント
採用された回答
Rik
2020 年 1 月 2 日
You can generate the list of file names with dir:
filelist=dir(fullfile(folder,'*_*.tif'));
Now you can optionally loop through this struct and remove any files that don't match the pattern of files you would like to read. (if you loop backwards, you don't need to worry about skipping any of the elements)
for n=numel(filelist):-1:1
if SomeCondition
filelist(n)=[];
end
end
And now you can use the struct to feed the file names to the geotiffread function, just like the documentation describes:
A=cell(size(filelist));
R=cell(size(filelist));
for n=1:numel(filelist)
fn=fullfile(folder,filelist(n).name);
[A{n},R{n}] = geotiffread(filename);
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!