How do we automatically read current folder name in matlab script to read all data?
Afficher commentaires plus anciens
I have attached below a part of my matlab script. The script is to read current sub-folders directory. As shown in the picture below "r20_" means the first 3 letter of current directory.
%get all subfolders of the main folders [stat,strf]=fileattrib; SubList = dir(fullfile(strf.Name, 'r20_*'));
Every time I change the current directory I need to edit the first 3 letter manually i.e. r20. I am thinking is there any way to read automatically the first three letter of current directory. Please note sublist in the part of code is used many times in rest of the code. So, while reading the three letter of current directory, sublist shouldn't affect for rest of the code. I appreciate your opinion. Thank you.
Réponse acceptée
Plus de réponses (1)
Dejia Kong
le 8 Juil 2019
I think
[~,name,~]=fileparts(pwd);
gives the current name and you can deal with your problem with this.
Catégories
En savoir plus sur File Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!