Having problem with the following line

1 回表示 (過去 30 日間)
Mariya Ali
Mariya Ali 2021 年 11 月 10 日
回答済み: Walter Roberson 2021 年 11 月 10 日
I am trying to load a file name in my code. I am actually trying to understand what does the following line do:
filename=Dir(k).name;
Because I feel it loads the files from another folder instead of the folder I have been computing the data from above.

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 11 月 10 日
The name field of the struct returned from dir() contains only the basic filename without any directory information. If you are working with a different directory than the current directory, then you need to put in the directory name. We recommend using fullfile() for that.
Example:
project = 'Scalp7';
Dir = dir(fullfile(project, '*.png'));
filename = Dir(1).name;
fullname = fullfile(project, filename) ;
img = imread(fullname) ;

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by