How to take an integral of a matrix

8 ビュー (過去 30 日間)
Radik Srazhidinov
Radik Srazhidinov 2019 年 1 月 14 日
コメント済み: Radik Srazhidinov 2019 年 1 月 15 日
I want to find an integral of a matrix:
T=[2 -sqrt(3) -1]';
R=[0.0042 -0.0755];
I=eye(3);
A=diag([7, 5, 2.05]');
B=[1 1 1]';
F=[-30.6722 17.8303 -0.3775];
fun=@(x) T*F*inv(exp(i*x)*I-A-B*F)*B*R*R'*B'*inv(exp(i*x)*I-A-B*F)'*F'*T';
q=integral(fun,0,2.*pi)
Can you please help me to correct the code? It is possible to use this integral function for matrix?
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 14 日
Do not use inv() for this purpose. Use \ instead.
You can precalculate much of that for performance reasons.
And do not do it all in an anonymous function, since the exp(j*x*I - A - BF) has to be calculated twice.
Radik Srazhidinov
Radik Srazhidinov 2019 年 1 月 14 日
Hi, thanks for reply. I have changed e to exp. My matrix is small, I don't worry for performance, I just want to able to calculate the integral

サインインしてコメントする。

採用された回答

David Goodmanson
David Goodmanson 2019 年 1 月 14 日
Hi Radik,
I assume you basically want to integrate each element in the resulting product matrix.
Lots of inner and outer products here. Looking at the overall product, R*R' is (row) x (col), a scalar inner product, so you can pull that out as an overall factor [where Matlab uses ' instead of the * that is in the formula]. The quantity
G = F*inv(exp(i*x)*I-A-B*F)*B
is (row) x (matrix) x (col) so it is also a scalar. Now that R*R' is out front, one can pull out G*G' and all that is left is T*T', which is the outer product (col) x (row). It's a matrix of rank 1. All together you have
(T*T')*(R*R')* Integral(G*G')dx
so you only have to integrate a scalar function of x. As Walter pointed out, in general it's better to use
G = F*( (exp(i*x)*I-A-B*F)\B )
instead of inv, but for a 2x2 it probably doesn't matter too much.
  6 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 15 日
Radik:
T=[2 -sqrt(3) -1]';
R=[0.0042 -0.0755];
I=eye(3);
A=diag([7, 5, 2.05]');
B=[1 1 1]';
F=[-30.6722 17.8303 -0.3775];
syms x real %changed
G=F*((exp(i*x)*I-A-B*F)\B);
W=R*R';
P=T*T';
f = G*G';
L=int(f,[0 2.*pi])
K=W*P*L;
Radik Srazhidinov
Radik Srazhidinov 2019 年 1 月 15 日
that is it, thank you Walter!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisualization and Data Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by