How to store all rows of a field from a structure into an array?
Mostrar comentarios más antiguos
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!
Respuestas (1)
Image Analyst
el 22 de Jul. de 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.
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!