how i correct error in Matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
I receice this error
Attempt to reference field of non-structure array
Error in perturb_method (line 136)
[j,k]=find(pop(i).mat.p==x)
댓글 수: 3
Jan
2021년 3월 11일
I've explained already how to use the debugger to find out, what the cause of the error message is. If pop(i).mat is not a truct, you cannot access a not existing field p . Without seeing your code and the data, it is impossible to guess, what you want to do instead.
What does Matlab show you, when it stops at the error message in debug mode, for:
class(pop)
class(pop(i).mat)
채택된 답변
Jan
2021년 3월 10일
편집: Jan
2021년 3월 10일
The error message means, that either pop or pop(i).mat is not a struct, such that you cannot access a field using the dot.
Check this with the debugger. Type this in the command window:
dbstop if error
Then run your code again until it stops at the error. Now check the classes:
class(pop)
class(pop(i).mat)
But I'd expect another error message:
find(pop(i).mat.p=x)
% ^
Inside the FIND command, you should use the == operator for the elementwise comparison, not = for assining a value.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!