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
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.
Friedrich
2011 年 8 月 11 日
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
2011 年 8 月 11 日
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
2011 年 8 月 11 日
1 件のコメント
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 Exchange で Programming についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!