cannot find files error

3 Ansichten (letzte 30 Tage)
Donal Walsh
Donal Walsh am 11 Mär. 2023
Kommentiert: Walter Roberson am 11 Mär. 2023
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 Kommentar
Walter Roberson
Walter Roberson am 11 Mär. 2023
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Special Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by