Convert structure to vector

134 views (last 30 days)
Gina Torres
Gina Torres on 9 Jul 2018
Commented: Gina Torres on 9 Jul 2018
Hello all,
I'm working with data in a structure type. For example:
M(1).vector=[0.3966;0.0829]
M(2).vector=0.87537
M(3).vector=0.64707
M(4).vector=[0.50874;0.04913;0.39537;0.27546;0.5889;0.61199;0.61578;0.78747;0.75151]
The Data for each row within the structure are small vectors as shown (Actually my structure has more than 1000 rows). I have this information separated like this because to each row I needed to apply different calculations. But now that all the calculations are done, I want to have this data as a 1 column vector. I have tried using something like cell2mat(struct2cell(M)) but I get errors.
The result that I'm looking for should look like this:
Result=[0.3966;0.0829;0.87537;0.64707;0.50874;0.04913;0.39537;0.27546;0.5889;0.61199;0.61578;0.78747;0.75151]
Any suggestions?

Accepted Answer

Adam
Adam on 9 Jul 2018
vertcat( M.vector )

More Answers (0)

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!