フィルターのクリア

Solving a complex system of differential equations

13 ビュー (過去 30 日間)
Ali Almakhmari
Ali Almakhmari 2023 年 11 月 15 日
コメント済み: Torsten 2023 年 11 月 15 日
I have a this differential equation system: , where F is a function of time (t). But I am not sure whats the easiest way to solve it in MATLAB. Lets say for example:
M = [1,0.8;0.8,7]
K = [5,0;0,10]
D = [0.15,0;0,0.35]
F = [5*exp(i*5*t); 3.65*exp(i*5*t)]
q = [X; Y]
And we want to solve for q, which is X and Y.

採用された回答

Torsten
Torsten 2023 年 11 月 15 日
編集済み: Torsten 2023 年 11 月 15 日
%q(1) = X, q(2) = Y, q(3) = Xdot, q(4) = Ydot
M = [1,0.8;0.8,7];
K = [5,0;0,10];
D = [0.15,0;0,0.35];
F = @(t)[5*exp(i*5*t); 3.65*exp(i*5*t)] ;
tspan = [0 1];
q0 = [0 1 1 0].';
fun = @(t,q)[[q(3);q(4)];inv(M)*(F(t)-(1i*D+K)*[q(1);q(2)])];
[T,Q] = ode45(fun,tspan,q0);
figure(1)
hold on
plot(T,real(Q(:,1)))
plot(T,imag(Q(:,1)))
hold off
figure(2)
hold on
plot(T,real(Q(:,2)))
plot(T,imag(Q(:,2)))
hold off
  2 件のコメント
Ali Almakhmari
Ali Almakhmari 2023 年 11 月 15 日
Is the first plot for q(1) and q(2) or is it for q(3) and q(4)? Because the definition of fun makes me think its q(3) and q(4)
Torsten
Torsten 2023 年 11 月 15 日
The first plot is for the real and imaginary part of q(1) = X, the second plot is for the real and imaginary part of q(2) = Y.
q(3) and q(4) are Xdot and Ydot, respectively (as written in the headline of the code).

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by