Why do I receive a warning about a value indexed with no subscripts?
조회 수: 27 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2019년 1월 2일
편집: MathWorks Support Team
2024년 4월 24일
Why do I receive the warning below that says a value was indexed with no subscripts, and this will be an error in a future release?
Warning: A value of class "<some class>" was indexed with no subscripts
specified. Currently the result of this operation is the indexed value
itself, but in a future release, it will be an error.
채택된 답변
MathWorks Support Team
2024년 4월 22일
편집: MathWorks Support Team
2024년 4월 24일
Starting with MATLAB R2023a, the behavior of indexing with no subscripts remains the same and does not error, but the warning no longer appears. Using the warning command to turn the warning on or off has no effect. For more information, see the linked MATLAB release note:
The source of a warning with the structure is code that uses indexing into variables with empty parentheses. This warning message is 'off' by default. In MATLAB R2017b, you can reproduce this warning by turning the warning on and indexing into an array without a subscript.
>> a = zeros(1, 3);
>> warning("on", "MATLAB:subscripting:noSubscriptsSpecified")
>> a()
Warning: A value of class "double" was indexed with no subscripts specified. Currently the result of this operation is the indexed value itself, but in a future release, it will
be an error.
ans =
0 0 0
If you are using MATLAB R2022b or earlier releases, you can turn off this warning. Execute this command in MATLAB to turn off the warning:
>> warning("off","MATLAB:subscripting:noSubscriptsSpecified");
댓글 수: 1
Nicholas Ayres
2020년 10월 22일
I'm working within the app editor and keep receiving this warning when I'm pressing buttons within the editor.
I assume the code that runs the editor must be the thing triggering this warning? as my code does not use the above. Hopefully the whole editor does not break in a future release!
추가 답변 (1개)
James Lebak
2024년 3월 26일
This warning was removed in R2023a. More details are in the release notes.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!