フィルターのクリア

How can I load all files using 'disp'?

5 ビュー (過去 30 日間)
Eva Sierra
Eva Sierra 2017 年 9 月 9 日
コメント済み: Eva Sierra 2017 年 9 月 9 日
Hi everyone,
I'm starting with Matlab and I would like to know how to use 'disp' for all the files inside a folder (within a loop). Each folder contains 6 files always. However, the last part of the name of the file is different. This is my script: disp(strcat('C:\CEDMATLAB\Neuroshare\',directory_name(sub).name,'\Part',directory_name(sub).name,'_','.smr'))
This is my result: C:\CEDMATLAB\Neuroshare\005\Part005_.smr
The original files are call like this: Part005_003.smr; Part005_007.smr; Part005_013.smr; Part005_015.smr; Part005_016.smr; Part005_023.smr.
I don't know how to insert the part of the filename after the'_' using 'disp'. I've tried to use a wildcard but is not supported by disp.
Any ideas? Thanks in advance,
Eva
  2 件のコメント
Simon MADEC
Simon MADEC 2017 年 9 月 9 日
編集済み: Simon MADEC 2017 年 9 月 9 日
try : A=dir(['C:\CEDMATLAB\Neuroshare\' directory_name(sub).name' '\' 'Part*smr'])
A.name
or disp(A.name)
Stephen23
Stephen23 2017 年 9 月 9 日
編集済み: Stephen23 2017 年 9 月 9 日
"How can I load all files using 'disp'?"
disp does not load files.
If you want to know how to process a sequence of files, why not simply read the MATLAB documentation?:
Or this thread:

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

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2017 年 9 月 9 日
%Here I am calling images, you can do similar way for files calling
path_directory='stare_test'; % 'Folder name'>Its should be in current working directory folder
original_files=dir([path_directory '/*.ppm']); %here PPM file extention name
for k=1:4 %length(original_files)here just example 4 its depends on number of files
filename=[path_directory '/' original_files(k).name];
image_ogi=imread(filename);
end
  1 件のコメント
Eva Sierra
Eva Sierra 2017 年 9 月 9 日
Thanks for your repply, but I have an error using your code: Conversion to struct from char is not possible. Any other suggestions?

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by