How to find a 2 π periodic solution?

1 回表示 (過去 30 日間)
JF
JF 2014 年 7 月 31 日
コメント済み: Patrick Johnson 2021 年 10 月 12 日
How to find a 2 π periodic solution for the Equation?; x" + 2 x' + x =cos(t)
Also I need to find the solution to: x" + 2 x' + x =cos(t), x(0)=x'(0)=0
finally I need to plot the graph. Thanks for you help

採用された回答

Yu Jiang
Yu Jiang 2014 年 8 月 4 日
>> syms x(t);
>> sol = dsolve('D2x+2*Dx+x = cos(t)', 't');
For the one with boundary conditions x" + 2 x' + x =cos(t), x(0)=x'(0)=0, you can try
>> syms x(t);
>> sol2 = dsolve('D2x+2*Dx+x = cos(t)', 'x(0)=0', 'Dx(0)=0');
To plot the answer stored in sol2, for example on the interval [0,10], you can do the following
>> t = linspace(0,10,1000);
>> plot(t,eval(sol2))
Notice that sol2 is a symbolic variable (See documentation for symbolic objects) , and therefore it needs to be evaluated before being executed. The way to do it is to use eval (See documentation for eval).
  • Alternatively, you may want to consider numerical ordinary differential equation solvers, such as ode45 (See Documentation). Take a look at Examples 2 and 3 in the documentation. Example 2 shows how to handle higher order terms and Example 3 illustrates how to deal with time-varying terms.

その他の回答 (1 件)

Roger Wohlwend
Roger Wohlwend 2014 年 8 月 4 日
Why don't you take a pen and a pencil and solve the equation analytically? In fact it is quite easy ....
  2 件のコメント
John D'Errico
John D'Errico 2014 年 8 月 4 日
While it is not an answer, I agree. +1
Patrick Johnson
Patrick Johnson 2021 年 10 月 12 日
It is possible that the pen and paper result is in need of an efficient check.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by