필터 지우기
필터 지우기

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

조회 수: 300 (최근 30일)
Anouar Nechi
Anouar Nechi 2021년 5월 17일
편집: Monika Jaskolka 2021년 5월 17일
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?

답변 (1개)

Monika Jaskolka
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', '')

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by