How do I access files not added to my matlab path?

조회 수: 33 (최근 30일)
cocopuffs
cocopuffs 2014년 7월 29일
댓글: harold 2019년 6월 8일
Hello everyone. I using the function 'dir' to access the names of the certain files in a folder. I then looping through them and organizing them in descending order and storing the ordered file names in a cell array. Now the next thing I wanting to do, is to read them using 'imread' and loop through the them to do some calculations.
The question is, how can I be using the function 'imread' on these file names without right clicking the folder, and clicking 'Add to Path'? Is there a simple function that does that for you?
Currently, I got the error saying 'Error using imread (line 349) File "lundimage00000.tif" does not exist'
Thank you all in the advanced.

채택된 답변

Michael Haderlein
Michael Haderlein 2014년 7월 29일
You know the path of the file, as you can use the dir function. Just add the path and you can open the file.
>> path='C:\Users\yourname\Pictures\';
>> files=dir([path '*.jpg']);
>> im=imread([path files(1).name]);
  댓글 수: 2
cocopuffs
cocopuffs 2014년 7월 29일
Thank you so much. This exact straightforward answer i was look for!
harold
harold 2019년 6월 8일
But it did not work, then I saw this page. It works ;)

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

추가 답변 (1개)

Sara
Sara 2014년 7월 29일
You need to provide to imread not just the file name but the full path. You can use fullfile to build it.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by