How to get file names only when using dir()?

423 vues (au cours des 30 derniers jours)
Anouar Nechi
Anouar Nechi le 17 Mai 2021
Hello I am trying to get only the file names after using the dir() function without using a for loop. For the moment I am doing the following:
clc;
clear;
folder = uigetdir();
fileList = dir(fullfile(folder, '*.mat'));
Is there a possible way to do what I want in order to be able to sort them and manipulate them easily?

Réponses (1)

Monika Jaskolka
Monika Jaskolka le 17 Mai 2021
Modifié(e) : Monika Jaskolka le 17 Mai 2021
fileList = {fileList.name}
If you want to remove the file extension:
fileList = strrep(filelist, '.mat', '')

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by