- dots, ".", are not allowed in field names.
- Try: Materials.('Acero').('Cuadrado').('C_15x15')
Can't acces existing struct
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
per isakson
2016-12-8
编辑:per isakson
2016-12-8
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!