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!