how do I make first name of my struct variable?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello all, I'm trying to make the first name of my struct variable but I can't figure out how to do it.
This works
test.a = 1;
List = 'a';
test.(List)
ans = 1
I'm trying to do the following:
test.a = 1;
List = 'test'
(List).a
%now I want to get the output test.a but I get:
(List).a
|
Error: Unexpected MATLAB operator.
Is it possible what im trying to do and if so how?
regards, Nick
2 comentarios
Friedrich
el 6 de Ag. de 2013
Why do you need this? This doesn't seem like a good way of programming. Maybe if you explain why you need this, we can help you with a better more suitable way of achieving your goal?
Respuesta aceptada
David Sanchez
el 6 de Ag. de 2013
List = 'test' ;
eval(strcat(List,' .a = 1'));
test =
a: 1
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Structures 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!