How to fix this error ? "attempt to reference field of non-structure array"

조회 수: 13 (최근 30일)
houda mejri
houda mejri 2017년 3월 29일
댓글: Walter Roberson 2020년 2월 9일
Hello, I had this error by declaring testset and classify as global variables. do you have an idea ? thank you
<<
>>

답변 (2개)

Jan
Jan 2017년 3월 29일
편집: Jan 2017년 3월 29일
Stephen's comment is exhaustive. Let me summarize it:
  • Obviously the variable testset has not been defined before or not in the required way.
  • Because it is a global variable, debugging is hard. You cannot directly find the code, which has (over-) written its value the last time.
  • This is the expected and known problem with global variables. If the variables are provided as inputs, it is trivial to use the debugger to find the source of the last change.
Poor solution: Dig in your code until you find the bad declaration of the global variable.
Good solution: Remove the global variables from your code and use a clean providing of inputs and outputs - or even more secure an object oriented approach.
  댓글 수: 4
Jan
Jan 2017년 3월 29일
@houda: Now you can provide the dataset and teh classifier as inputs to myfunctiontominimize, see e.g. http://www.mathworks.com/matlabcentral/answers/1971

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


Joshah Magdalene
Joshah Magdalene 2020년 2월 9일
I too have the same error.
Attempt to reference field of non-structure array.
I find this error in the below line of my code.
index = int32(pose.subset(j))+1;
I will be grateful if it is sorted out. Thank You!
  댓글 수: 4
Joshah Magdalene
Joshah Magdalene 2020년 2월 9일
Thank you!
I have another query.
Is there any function like subset() and candidate() in Matlab?
If so what do they do?
Thanks in advance!
Walter Roberson
Walter Roberson 2020년 2월 9일
I do not find functions by those names in MATLAB. Possibly some third-party toolbox.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by