help in sorting through a concatenated data

조회 수: 1 (최근 30일)
hasnain ali
hasnain ali 2021년 3월 15일
편집: Aghamarsh Varanasi 2021년 3월 17일
hey guys i am trying to sort through a concatenated data which i got by reading a .mat file for a month and concatenated them together. now i have to acess the data from that file which is a structure with fields and have a cell array for every data figure attached below. i have to sort through this data for example i have to gather the time stamp for the whole month from that data and concatenate them together and then make a double array with another data point from the sheet but i can't seem to figure that out.
the code i used to put them together is added as well
% clear
% PathName = uigetdir;
% file_all = dir(fullfile(PathName,'*.mat'));
% matfile = file_all([file_all.isdir] == 0);
% clear file_all PathName
% d=dir('*.mat'); % get the list of files
% x=[]; % start w/ an empty array
% for i=1:length(matfile)
% x=[x; load(matfile(i).name)]; % read/concatenate into x
% end
  댓글 수: 3
hasnain ali
hasnain ali 2021년 3월 15일
tried cell2mat as well
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 42)
cellclass = class(c{1});
Error in January (line 29)
A= cell2mat(x);
gives me this error
hasnain ali
hasnain ali 2021년 3월 15일
load('january.mat')
A=[];
for i=1:length(x)
% S = vertcat( A , x.PCTimeStamp(i));
s=x.PCTimeStamp(i);
end
Expected one output from a curly brace or dot indexing expression, but there were 31 results.
Error in January (line 26)
s=x.PCTimeStamp(i);
if i try this code i get this error

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

답변 (1개)

Aghamarsh Varanasi
Aghamarsh Varanasi 2021년 3월 17일
편집: Aghamarsh Varanasi 2021년 3월 17일
Hi,
The variable 'x' in your attached screenshot is a structure array, which can be accessed in the following way.
s = x(i).PCTimeStamp;
For more info, refer to Structure Arrays and Access Elements of a Nonscalar Structure Array documentation pages.
If you want to sort the elements in the variable 'x' refer to this.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by