Second order ODE with initial conditions

I'm trying to understand how to plot a signal in matlab without success. I saw that the program doesn't work directly with equations of higher orders, it's necessary to turn into first order equations. I tried to use ODE45 but with no sucess too.
The equation is: D2x + 0.1*Dx + x^5 = 6*sin(t), with t ranging from [0 50]
Initial values: x(0)=2 Dx(0)=3
Could someone please help me understand how to make matlab to solve the issue?

回答 (3 件)

Walter Roberson
Walter Roberson 2011 年 8 月 11 日

1 投票

I worked for a while with this in Maple. The only solution I have found so far is a series solution. It starts x(t) = 2 + 3 * t . The pattern of signs for the terms after that is not immediately obvious to me. Each of the subsequent terms involves an increasing constant times t to a power, so the series is divergent and goes to roughly +/- 10^N for t=50 for truncation order N.
Therefore, unless by working it through you can observe the pattern of powers and convert that to a nice divergent transcendental function, I am not sure you are going to be able to come up with an explicit solution.

1 件のコメント

Gustavo Santana
Gustavo Santana 2011 年 8 月 11 日
Thx for the reply, but my difficulty is more a practical problem. I'm not able to plot the solution of the ODE mentioned. I'm trying to learn how to enter commands at matlab. If you can help me I would greatly appreciate it.

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

Friedrich
Friedrich 2011 年 8 月 11 日

1 投票

Hi,
Based on this article (chapter 2.3)
I would do something like this:
function example( )
x_0 = [2,3];
tspan = [0,50];
[t,y] = ode45(@my_func,tspan,x_0);
%y(1) = x
%y(2) = x'
%x'' = 6sin(t)-0.1y(2)-y(1)^5
hold on
plot(t,y(1))
plot(t,y(2))
plot(t,6*sin(t) - 0.1*y(2) - y(1).^5)
hold off
%transform 2nd order ode to couples system of 1st order systems
%x_1 = x
%x_2 = x'
%==> x_1' = x_2
% x_2' = 6sin(t)-0.1x_2-x_1^5
function out = my_func(t,x)
out = [x(2); 6*sin(t) - 0.1*x(2) - x(1).^5];
end
end

2 件のコメント

Gustavo Santana
Gustavo Santana 2011 年 8 月 11 日
I understand the operation and basically read the entire file, but do not know why I can't plot the solution. In the case of the above code, I get the message: "Error: Function definitions are not permitted in this context."
I understand the theory but I can not do the run matlab plotting. I'm studying about this software so I'm facing some difficulties.
PS: I use Matlab R2010b
Walter Roberson
Walter Roberson 2011 年 8 月 11 日
Function definitions *are* permitted in that context, provided you wrote the whole code to example.m and executed that. You cannot paste code with functions to the command window.

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

Gustavo Santana
Gustavo Santana 2011 年 8 月 11 日

0 投票

Really Function definitions are permitted in that context. After save the .m archive worked well, but the result aren't crrect i think. Below I put a link in the resulting plot (Fig1) and I should find (Fig. 2). Why graphics are not the same? Please, how can I get the plot of Fig 2?
http://imageshack.us/f/43/resultsjr.png/

1 件のコメント

Walter Roberson
Walter Roberson 2011 年 8 月 11 日
I made no claim that Friedrich's code was correct. His plot completely disagreed with the analysis I did in Maple. On the other hand, I did indicate that the path I was following was leading to a divergent solution that could not reasonably be truncated at any order -- which is consistent with the description of the response characteristics as given in that link. Unless I am able to find a finite but unstable representation, I do not see how it could be symbolically constructed.

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

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

質問済み:

2011 年 8 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by