cannot find files error

3 次查看(过去 30 天)
Donal Walsh
Donal Walsh 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