MATLAB Answers

what does . and .. refer to

67 views (last 30 days)
Matlab works
Matlab works on 26 Jan 2020 at 4:33
Commented: Image Analyst on 27 Jan 2020 at 1:10
for i = 1:size(TrainFiles,1)
if not(strcmp(TrainFiles(i).name,'.')|strcmp(TrainFiles(i).name,'..')|strcmp(TrainFiles(i).name,'Thumbs.db'))
Train_Number = Train_Number + 1; % Number of all images in the training database
name{Train_Number}=TrainFiles(i).name;
end

  1 Comment

Walter Roberson
Walter Roberson on 26 Jan 2020 at 22:52
User completely changed the question. However, the revised question is valid in itself.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 26 Jan 2020 at 16:12
It's checking to make sure that the file is not the current folder (dot) or a link to the parent folder (dot dot).

  3 Comments

Image Analyst
Image Analyst on 26 Jan 2020 at 22:44
Actually, since it's just building up a cell array of image files, you'd be better off doing this:
% Get a list of all PNG image files in the specified folder.
filePattern = fullfile(yourImageFolder, '*.png') % Or whatever your image extension is
fileStructure = dir(filePattern) % Get info from all PNG files into a strcuture array.
% Now extract all the names from the file structure fields into a single cell array:
allFileNames = {fileStructure.name}
Walter Roberson
Walter Roberson on 26 Jan 2020 at 22:52
I would use
allFileNames = fullfile(yourImageFolder, {fileStructure.name});
Image Analyst
Image Analyst on 27 Jan 2020 at 1:10
Yes. Or you could even use imDatastore().

Sign in to comment.


Steven Lord
Steven Lord on 26 Jan 2020 at 16:57
For the operating systems on which MATLAB is supported, . refers to the current directory and .. the parent directory, as stated on this Wikipedia page.

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by