How to declare a structure as global
2 ビュー (過去 30 日間)
古いコメントを表示
How can I access a structure defined in a for loop, outside the for loop??
0 件のコメント
回答 (2 件)
Walter Roberson
2012 年 4 月 16 日
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.
0 件のコメント
Tom
2012 年 4 月 16 日
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, ' '.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!