Sym Matrices can be Indexed with non-Logical/non-Integer. Bug?

조회 수: 2 (최근 30일)
Paul
Paul 2021년 9월 1일
댓글: Paul 2021년 9월 3일
Linear indexing into a sym array:
A = sym([1 2;3 4])
A = 
A(.5)
Warning: Integer operands are required for colon operator when used as index.
ans = 
1
A(1.1)
Warning: Integer operands are required for colon operator when used as index.
ans = 
1
A([1.2 2.2])
Warning: Integer operands are required for colon operator when used as index.
ans = 
But element indexing produces an error
A(1.2,2.2)
Index in position 2 is invalid. Array indices must be positive integers or logical values.

Error in sym/subsref (line 909)
R_tilde = builtin('subsref',L_tilde,Idx);
But note that the error message is about the index in position 2. For a real array the error is the index in the first position.
I assume that this is a bug?
  댓글 수: 2
Bjorn Gustavsson
Bjorn Gustavsson 2021년 9월 1일
It seems to be happy to treat A as a 1-D array, or a 2-D array with rounding of the first-dimension index, as long as the second index is an integer. This is clearly a "feature".
Paul
Paul 2021년 9월 3일
Apparenty it is a "feature." I submitted to Tech Support and the response said a change in behavior has been submitted as an enhancement request. Seems like a bug to me.
I wonder if there are any other objects that have the same behavior as sym objects.

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

답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by