- dots, ".", are not allowed in field names.
- Try: Materials.('Acero').('Cuadrado').('C_15x15')
Can't acces existing struct
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I'm learning some about matlab. By now i'm trying to get the fields names by code with fieldnames(), but trying to fix it with Material.(s) by now.
This is a part of my code with the problem:
Material.Acero.Cuadrado.C_15x15=[1 1.5] %Creates the struct
Material.Acero.Cuadrado.C_15x15 %Just to verify it's existence
s=strjoin(t,'.') %Develop in another part of the code and returns for example 'Acero.Cuadrado'
class(s) %Just for check
size(s) %Just for check
Material.(s)
And returns the following:
Material =
Acero: [1x1 struct]
ans =
1.0000 1.5000
s =
Acero.Cuadrado.C_15x15
ans =
char
ans =
1 22
Reference to non-existent field 'Acero.Cuadrado.C_15x15'.
Error in test3>Datos (line 516)
Material.(s)
Error while evaluating Table CellEditCallback
I have manage to get just s='Acero' and it works fine. So it seems that Material.(s) is ignoring the dots and is taking ,for example, 'Acero.Cuadrado.C_15x15' as a complete field name and not subfields.
I have also trying the following codes:
s=sprintf('.%s',t{1:end-1},t{end})
--> Returns class:char and "non-existent field" even for s='Acero'
for i=2:1:col
s=strcat(s,'.',table2(row,i))
end
--> Returns class:cell and "Argument to dynamic structure reference must evaluate to a valid field name."
2 Commenti
per isakson
il 8 Dic 2016
Modificato: per isakson
il 8 Dic 2016
Risposte (0)
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!