Why do I receive an error when I run the example code in the help documentation page titled "Using Dynamic Field Names"?
1 回表示 (過去 30 日間)
古いコメントを表示
The example code in the help documentation page under "MATLAB -> Programming -> Data Types -> Structures -> Using Dynamic Field Names" seems to show that structures can have field names with spaces in them. However, when I try to create a structure with a dynamic field name that contains a space, I receive an error message:
str = 'Ann Lane';
x.(str) = 5;
??? Invalid field name: 'Ann Lane'.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is an error in the documentation for dynamic field names, in that the names of structure fields cannot have spaces. As a workaround, use 'Ann_Lane' and 'William_King' as the dynamic field names, instead of 'Ann Lane' and 'William King':
str = 'Ann_Lane';
x.(str) = 5;
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!