Why do I receive an error when I run the example code in the help documentation page titled "Using Dynamic Field Names"?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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'.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Calendar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!