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 Exchange에서 Programming에 대해 자세히 알아보기

제품

질문:

2011년 8월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by