- 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!