cannot find files error

조회 수: 2 (최근 30일)
Donal Walsh
Donal Walsh 2023년 3월 11일
댓글: Walter Roberson 2023년 3월 11일
I'm being asked to carry out analysis on images withing a dataset called ImageDatasets specifically looking at a folder withing this folder called DATASET 1. I'm using the code below yet it gives me the error saying it cannot find the files. I have taken this path directly from my computer so I don't understand why it cannot find the files. All files in dataset 1 are .jpg images.
imds = imageDatastore('C:/Users/donal/Desktop/ImageDatasets/DATASET 1/*.jpg');
Can anyone help me understand where I'm going wrong?
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 3월 11일
To debug
location = 'C:/Users/donal/Desktop/ImageDatasets/DATASET 1/*.jpg';
pieces = strsplit(location, '/');
numpieces = length(pieces);
last_valid = 0;
for K = 1 : numpieces
sofar = fullfile(pieces{1:K});
dinfo = dir(sofar);
if isempty(dinfo); break; end
last_valid = K;
end
if last_valid == 0
fprintf('NOTHING in the path was found, not even the hard disk!\n');
else
fprintf('found up to "%s"\n', sofar);
if last_valid == numpieces
fprintf('which is the entire path\n');
else
fprintf('but not "%s"\n', pieces{last_valid+1});
end
end

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Special Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by