Combine multiple matrix variables into a structure?
Mostrar comentarios más antiguos
I currently have 180 matrix variables (1336 x 4) that I would like to make into a structure to make it easier to work with. In the end I want to be able to plot all of this data in the same way on separate plots or subplots.
What is the best way to combine the matrices? I am able to create a structure using 'whos' and then add on a 'data' field of zeros to put the final data in but how would I transcribe all of the variable data into the structure? The variables are not concurrently named so I am struggling to get a for loop to work.
3 comentarios
Stephen23
el 4 de Sept. de 2018
@Kirsty Alsop: the most important question is how did you get those 180 matrices into the workspace? Presumably you did not sit and write them all out by hand, in which case they must have been imported somehow, or generated in a loop somehow... and that is the correct location to fix this problem! If you tell us how these variables first got into your workspace, then we can show you better ways to design your code, so that your data handling is simpler, more efficient, and less buggy.
Magically accessing variable names is one way that beginners force themselves into writing slow, complex, buggy code that is hard to debug. Read this to know why:
Kirsty Alsop
el 4 de Sept. de 2018
Walter Roberson
el 4 de Sept. de 2018
The best approach would be to not get into this situation, to store the information in a structured manner instead of in separate variables.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Get Started with MATLAB 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!