mpower doesn't work with symbolic matrix

조회 수: 3 (최근 30일)
fi
fi 2022년 7월 7일
답변: Torsten 2022년 7월 7일
I'm trying to create a symbolic experession of a matrix A raised to the power n, using a symbolic matrix variable (as introduced in R2021a).
However, I always get the following error:
% Create a symbolic 2x2 matrix
syms A 2 matrix
% Create a symbolic integer
syms n
assume(n, {'integer', 'positive'})
% Perform A^n
A^n
Error using ^
Invalid argument at position 2. Value must be integer.
MATLAB says n isn't an integer, even though it is defined to be one. What am I doing wrong?
The same thing also happens when using the explicit syntax (mpower(A, n)).
----
Related documentation: (can't find anything about this in there)

답변 (2개)

KSSV
KSSV 2022년 7월 7일
syms A 2 matrix
syms n
assume(n, {'integer', 'positive'})
A.^n
ans = 
  댓글 수: 1
fi
fi 2022년 7월 7일
That's not mpower. A.^2 performs the operation element-wise (see power, .^).
What I want is matrix power as in A^2 = A*A (see mpower, ^).

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


Torsten
Torsten 2022년 7월 7일
A = sym('a%d%d', [2 2]);
A^2
ans = 

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by