Use entries of symbolic array outside of the array

조회 수: 1 (최근 30일)
Tobias Ohrmann
Tobias Ohrmann 2020년 3월 28일
댓글: Tobias Ohrmann 2020년 3월 28일
I have defined a matrix of symbolic variables via
X=sym(x,[8,24]);
When I now type x5_24 for instance, MATLAB still says "Unrecognized function or variable x5_24". Why? I need to use the variable entries outside of the matrix X.

채택된 답변

Star Strider
Star Strider 2020년 3월 28일
The reason is that the elements of ‘X’ are stored as matrix elements. The individual elements exist only as matrix elements, not as individual, named variables:
syms x
X=sym('x',[8,24]);
Q = X(5,24)
produces:
Q =
x5_24
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 3월 28일
Read here why it is a bad idea: https://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer. Is there a reason that you cannot use matrix indexing to access an element?
Tobias Ohrmann
Tobias Ohrmann 2020년 3월 28일
Its a bit complicated, I transported the matrix X to Mathematica, did something with it there and got a new matrix with variables xi_j, which I now want to transport back to MATLAB. So appareantly this was a bad idea..

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by