Reading many files in one loop

조회 수: 2 (최근 30일)
John
John 2013년 4월 4일
How can I read file names and convert them to a matrix? I have more than one file and I want to read their contents in one loop of the program. Thanks
  댓글 수: 3
Jan
Jan 2013년 4월 4일
It is not useful to convert filenames to a matrix. Do you want to import the file's contents into a matrix?
John
John 2013년 4월 12일
no I need to read the contents of a specific folder's file names (as text), then run selection rule to pick names only that i want.
The problem is that files being send to a folder, with names of the format (yyyymmddhh.jpg) so each day there is a marked file as (yymmddT.jpg)... (T for terminate). The names are varying, i can't read all by fopen commands, i can't specify the required name unless they are in some form.

댓글을 달려면 로그인하십시오.

채택된 답변

Ahmed A. Selman
Ahmed A. Selman 2013년 4월 18일
Download a function file called folderFiles.m.
It'll do the job for you, hopefully.

추가 답변 (2개)

ChristianW
ChristianW 2013년 4월 4일
doc dir
D = dir([myfolder 'my*file*name*.*']);
files = {D.name}';
  댓글 수: 2
John
John 2013년 4월 12일
how to use files? I used it like
D = dir(['C:\Documents and Settings\John\My Documents\MATLAB\Pic_Down' '*.jpg'])
files = {D.name}';
files =
{}
any ideas?
Jan
Jan 2013년 4월 18일
편집: Jan 2013년 4월 18일
This means, that no file matchs the filter:
'C:\Documents and Settings\John\My Documents\MATLAB\Pic_Down*.jpg'
Perhaps you want:
'C:\Documents and Settings\John\My Documents\MATLAB\Pic_Down\*.jpg'
Note: fullfile() is much better for constructing file names than STRCAT, HORZCAT or [.].

댓글을 달려면 로그인하십시오.


Jan
Jan 2013년 4월 4일
It is always a good idea to read the FAQ, because it is efficient to profit from the errors of others.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by