Why Struct contents reference from a non-struct array object occurs?

조회 수: 14 (최근 30일)
sri Jagarlmudi
sri Jagarlmudi 2018년 11월 1일
댓글: Image Analyst 2022년 4월 21일
Hi, When I'm executing the code, I always face the problem 'Struct contents reference from a non-struct array object. In my program every time it is showing this error in such cases
'varnames = old.allVarNames'
Can anyone please tell me why it occurs and what should be the solution in above case?
  댓글 수: 3
madhan ravi
madhan ravi 2018년 11월 1일
You still didn’t provide enough information needed
Walter Roberson
Walter Roberson 2018년 11월 1일
Is old created by using load() or importdata()?

댓글을 달려면 로그인하십시오.

답변 (3개)

Stephan
Stephan 2018년 11월 1일

Image Analyst
Image Analyst 2018년 11월 1일
Set a breakfront there and then double click old in the workspace to bring it up in the variables window. Or type old on the command line. You will see its values, and that it is not a structure, but some other type of variable:
>> whos old
>> old

Ouafae errachedy
Ouafae errachedy 2022년 4월 21일
I always face the problem 'Struct contents reference from a non-struct array object. In my program every time it is showing this error.
Struct contents reference from a non-struct array object.
Error in updateApp (line 6)
str1 = num2str(rto1.InputPort(1).Data);
Can anyone please tell me why it occurs and what should be the solution
  댓글 수: 1
Image Analyst
Image Analyst 2022년 4월 21일
The reason is that your rto1 variable is not a structure or static class so you can do "dot anything". Or if rto1 is a structure, then rto1.InputPort(1) is not a structure with a field called "Data".
The answer is the same as for the original poster.
Set a break point there and look in the workspace at the variable to see what it actually is. Or when stopped there, put this in the command window
>> whos rto1
>> rto1

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by