필터 지우기
필터 지우기

How to save label in 1x1 categorical?

조회 수: 1 (최근 30일)
Faheem Ur Rehman
Faheem Ur Rehman 2021년 4월 20일
댓글: Faheem Ur Rehman 2021년 4월 20일
I have .mat file which dimension is (1024x1) and i want to give name that .mat file in 1x1 categorical. when i load that .mat file the output shoud be

답변 (1개)

Walter Roberson
Walter Roberson 2021년 4월 20일
projectdir = '/path/to/files'; %could be '.'
dinfo = dir( fullfile(projectdir, '*.mat'));
filenames = fullfile({dinfo.folder}, {dinfo.name});
nfiles = length(filenames);
frames = cell(nfiles,1);
labels = cell(nfiles,1);
%do not assume that the variable names are the same for each time
for K = 1 : nfiles
thisfile = filenames{K};
[~, basename, ~] = fileparts(thisfile);
filestruct = load(thisfile);
fields = fieldnames(filestruct);
frames{K} = filestruct.(fields{1});
labels{K} = categorical(basename);
end
output = cell2struct([frames,labels], {'frame', 'label'}, 2);
The output will be a (number of files x 1) struct array with fields 'frame' and 'label'
  댓글 수: 1
Faheem Ur Rehman
Faheem Ur Rehman 2021년 4월 20일
The output is not matched what i want.
I have attached .mat file please add label in it in categorical form.

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

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by