How to declare a structure as global

Respuestas (2)

Walter Roberson
Walter Roberson el 16 de Abr. de 2012

0 votos

Any variables defined within the loop will continue to exist after the loop, until the defining function returns.
If you are defining the structure in the for loop, are you possibly overwriting the structure in each iteration of the loop? That could be a problem for you.
Tom
Tom el 16 de Abr. de 2012

0 votos

The easiest way would be to preallocate it from outside the for loop. In MATLAB, you don't have to declare variables, but you can create the variable and fill it with zeros, or empty strings, ' '.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Abr. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by