Accessing a column of a structure array

조회 수: 221 (최근 30일)
ardeshir moinian
ardeshir moinian 2021년 8월 3일
댓글: Stephen23 2021년 8월 3일
I have multiple *.spc files in a folder which I want to access. I use the following code to get the file names:
folder_cal = uigetdir('','select calibration data folder');
Files_cal=dir(fullfile(folder_cal,'*.spc'))
Files_cal is a structure array, when I enter Files_cal in command window I get:
Files_cal =
84×1 struct array with fields:
name
folder
date
bytes
isdir
datenum
I want to get the file names but when I use:
names=Files_cal.name
I get only one of the names (the first row). Can anyone tell me what am I doing wrong and how can I get all file names at the same time?
I can convert this stucture array to a cell format and solve the problem. But I want to learn how to handle structures.
Thank you in advance!

채택된 답변

KSSV
KSSV 2021년 8월 3일
names = {Files_cal (:).name} ;
celldisp(names)
  댓글 수: 1
ardeshir moinian
ardeshir moinian 2021년 8월 3일
Thank you for your answer. It worked, I had to make a small change
names = {Files_cal(:).name} ; % I removed the space between Files_cal and (:)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by