How to get file names only when using dir()?
298 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Monika Jaskolka
2021-5-17
编辑:Monika Jaskolka
2021-5-17
fileList = {fileList.name}
If you want to remove the file extension:
fileList = strrep(filelist, '.mat', '')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!