How to store all rows of a field from a structure into an array?

5 views (last 30 days)
I'm working with a struct (s) in MATLAB. A field in this struct is called dF, which is a 1x600 double. There are a variable number (n) of rows (1x600 doubles). How do I store all the rows into one array (n x 600)?
When I enter the line: s.dF, I get n outputs corresponding to each 1x600 double. When I try to access individual elements by doing s.dF(3), I get error messages.
What's the right way to do this?
Thanks!

Answers (1)

Image Analyst
Image Analyst on 22 Jul 2018
You mean like using vertcat()?
s(1).df = randi(100, 1, 600);
s(2).df = randi(100, 1, 600);
all_df = vertcat(s.df) % Make 2-by-600 matrix.

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!