필터 지우기
필터 지우기

Calling a Field of a Struct by a Pre-defined String Variable

조회 수: 1 (최근 30일)
Rightia Rollmann
Rightia Rollmann 2017년 2월 7일
댓글: Stephen23 2017년 2월 7일
I want to call a field of a struct by a string variable named like that field, but I receive the error “Reference to non-existent field …”. How can I solve this problem? I mean how can I define a name of a field with a string variable and then add this string variable to struct to call the field?
A.B = 'B1'; % Assign the value B1 to field B
C = 'B' % Assign the value B to variable C
A.C % I receive the error “Reference to non-existent field 'C'.”

채택된 답변

Guillaume
Guillaume 2017년 2월 7일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by