MATLAB Answers

how to extract data from structure efficiently

14 views (last 30 days)
Micke Malmström
Micke Malmström on 13 Apr 2016
Commented: MnM on 16 Apr 2016
I have this structure with sometimes allot of A_scans:
>> Data.CH1
ans =
name: 'CH1'
Props: [1x1 struct]
A_scan1_1: [1x1 struct]
A_scan1_2: [1x1 struct]
A_scan1_3: [1x1 struct]
A_scan1_4: [1x1 struct]
A_scan1_5: [1x1 struct]
Where ecach scans has a "data" variable, that I want to put in a matrix row by row:
ans =
name: 'A_scan1_1'
Props: [1x1 struct]
data: [1x31990 int16]
What is the most efficient way of extracting the "data" arrays into a matrix? I guess i could do a forloop but I have a feeling there might be a faster way?
MnM on 16 Apr 2016
the data comes from a tdms file.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 13 Apr 2016
The more efficient way to extract it efficiently is to use a single A_scan1 that is indexed -- a struct array. Then you could do something like horzcat(

Community Treasure Hunt

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

Start Hunting!

Translated by