How to convert nested structure to contain its original data?

2 views (last 30 days)
I'm new, and I need some help. So I have these multiple signals in double, .mat format and I managed to load them all as output using this simple code. And I want to further analyze this dataset.
data signal
But the output sets the values as struct, which doesn't allow me to conduct batch processing such as feature extraction on it, or import it in the Diagnostic Toolbox.
I want the data in the cell array to be as double, not struct. May I know how to solve this? Or it is bc there's something with my data?
  9 Comments
Jan
Jan on 15 Apr 2021
"in another set of array/table" - please do not let the reader decide, if you want a table or array. This is your decision.
Aisya Amelia
Aisya Amelia on 15 Apr 2021
Edited: Aisya Amelia on 15 Apr 2021
Hello @Stephan ! I did try after you suggested it, but it ended up loading all .mat files as separate variables in the workspace: when i opened mydata, it was just empty, [ ] . If I do not assign the result of load to a variable, how do I load them as one output? thank you!

Sign in to comment.

Accepted Answer

Jan
Jan on 15 Apr 2021
myFolder1 = ('C:\Users\User\Documents\Signals');
mysignals = dir(fullfile(myFolder1, '**', '*.mat'));
N = numel(mysignals);
mydata = cell(N,1);
for k = 1:N
File = fullfile(mysignals(k).folder, mysignals(k).name);
Data = load(File);
mydata{k} = Data.P2V1; % Or P2V3 or what ever?
end
  4 Comments
Aisya Amelia
Aisya Amelia on 15 Apr 2021
Edited: Aisya Amelia on 15 Apr 2021
Each .mat file is a signal of m x 1 cell array. The variable of each signal are of numeric values (conductance). I want to import these arrays of values.
Jan
Jan on 15 Apr 2021
All we need to knwo for the solution is the name of the variable stored in the MAT file. Replace my "P2V1" by the name of this field. I've written "or what ever" in the hope, that you can adjust it accordingly.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!