Working with structures and combining them
1 view (last 30 days)
Show older comments
I have a bunch of data that was saved in individual data structures. I would like to combine them so I can work the dataset as whole. See example below:
data1 =
lambda: [1024x1 double]
data: [1024x8 double]
err: [1024x8 double]
fl: [1024x8 double]
flerr: [1024x8 double]
Ns: 1
Nd: 8
Nw: 1024
t: [0.0500 0.0500 0.0500]
P: 0
z_s: 0
r_sd: [0.1200 0.1800 0.2400 0.3000 0.4000 0.5000 0.6000 0.8000]
fr_sd: [0.1200 0.1800 0.2400 0.3000 0.4000 0.5000 0.6000 0.8000]
data_files: {[1x144 char]}
data_file_map: [3x2 double]
corrections: {{6x2 cell}}
sample: {'D2_postPDT_abdo. wall_ref_1(1)'}
n_frames: 4
data2 =
lambda: [1024x1 double]
data: [1024x8 double]
err: [1024x8 double]
fl: [1024x8 double]
flerr: [1024x8 double]
Ns: 1
Nd: 8
Nw: 1024
t: [0.0500 0.0500 0.0500]
P: 0
z_s: 0
r_sd: [0.1200 0.1800 0.2400 0.3000 0.4000 0.5000 0.6000 0.8000]
fr_sd: [0.1200 0.1800 0.2400 0.3000 0.4000 0.5000 0.6000 0.8000]
data_files: {[1x139 char]}
data_file_map: [3x2 double]
corrections: {{6x2 cell}}
sample: {'D2_postPDT_Aorta_ref_1(1)'}
n_frames: 4
I want to create a new data structure that would combine these two and would look something like this:
totdata =
lambda: [1024x1 double]
data: [1024x9x2 double]
err: [1024x9x2 double]
fl: [1024x9x2 double]
flerr: [1024x9x2 double]
Ns: 2
Nd: 9
Nw: 1024
t: [1x4 double]
P: [2x1 double]
z_s: [2x1 double]
r_sd: [0.1200 0.1800 0.2400 0.3000 0.4000 0.5000 0.6000 0.8000]
fr_sd: [0.1200 0.1800 0.2400 0.3000 0.4000 0.5000 0.6000 0.8000]
data_files: {2x1 cell}
data_file_map: [4x2 double]
corrections: {1x2 cell}
sample: {2x1 cell}
n_frames: [4 4]
I have about 100 of such data files, any suggestions on how to handle this?
Many many thanks in advance!
4 Comments
Jurgen
on 21 Feb 2013
Sounds like you want to make a class with special methods, e.g. datanew = data1 + data2 where the '+' is overloaded.
Answers (1)
Azzi Abdelmalek
on 20 Feb 2013
Edited: Azzi Abdelmalek
on 21 Feb 2013
Let us guess, Maybe you want something like this
data1=struct('data',num2cell(1:10))
data2=struct('data',num2cell(11:20))
totdata=[data1 data2]
%or
totdata=[data1 ;data2]
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!