How to solve a second order nonlinear differential equations with a step function
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
for 0<=t<=10 solve
5 x'' + x' + t x^3 = t + 3 u(x) where u(x) = 1 for 1<=x<=2
=0 otherwise
채택된 답변
Edit: The
is not signum-based, and the constraint for the velocity
is defined in an Event function called velocityEventsFcn.
options = odeset('Events', @velocityEventsFcn);
[t, x, te, xe, ie] = ode23s(@odefcn, [0 10], [0.5 1.5], options);
plot(t, x, 'linewidth', 1.5)
function dxdt = odefcn(t, x)
dxdt = zeros(2, 1);
u = max(0, min(min(100000*x(1) - 99999, 1), min(1, -100000*x(1) + 200001)));
dxdt(1) = x(2);
dxdt(2) = (t + 3*u - (x(2) + t*x(1)^3))/5; % 5*x" + x' + t*x^3 = t + 3*u(x)
end
function [position, isterminal, direction] = velocityEventsFcn(t, x)
position = x(2); % When velocity x(2) = 0,
isterminal = 1; % the integration stops,
direction = 0; % and the velocity cannot go into negative no matter what
end

댓글 수: 13
can you write u different way without using signum function ? and add one more thing that x(2) cant be negative for this whole simulation.
ode45 and related functions are not compatible with discontinuous functions. You would need to stop at the boundaries and restart.
Effective clarification will improve the communication. I have two queries.
Query #1:
Perhaps I interpreted your u(x) incorrectly. It is true that ode45 does not work well with jump discontinuities. Would you enlighten exactly which part of the mathematics that incorrectly describes
? Or, the signum function is disallowed by your Professor? Or, a fancy continuous function is preferred?
x = 0:0.01:3;
u = max(0, min(min(1000*x - 999, 1), min(1, -1000*x + 2001)));
plot(x, u, 'linewidth', 1.5)
grid on
xlabel('x')
ylabel('u')
ylim([-0.5 1.5])

Query #2:
You have mentioned that
cannot be negative for the entire simulation. Does your ODE correctly reflect this? The ODE solver only integrates the differential equations that are given. If you can provide a little more critical information about the system that you want to simulate, then it will be helpful in the coding process.
At u(1) and u(2) , It's not mandatory to use ode45 only.
Actually
is the velocity then how to put a condition that
is the velocity then how to put a condition that
@Sudipta Mukherjee, Still waiting for your technical reply on Query #1. Why would you want to avoid using signum function to describe
? Is the newly proposed function acceptable to describe
?
On
, we know nothing about the physical dynamics of your system. Either the differential equations are modeled by you, or they come from a reference (your supervisor, books, journal paper, etc.).
then u(1)=u(2)=Thanks for your clarification. Now I see...
If
is strictly desired, and the proposed signum-based boxcar function gives
, then the requirement
is not met.
is strictly desired, and the proposed signum-based boxcar function gives However, thinking deeper, would x (position) reach
or
in finite time?
I'm just trying to help and I know that
is a piecewise function. What mathematical differentiable function do you suggest for
? Anyhow, I have edited the Answer to run the sim for
.
if
then what will be the u(x) function in the matlab code?
I did't try, but you can use the non-signum template to design for the new
.
u=0
if x(1)>=0 && x(1)<=10^-9
u=1;
end
can i use this?
Yes, go ahead. It can't hurt, at least not more than what you are already doing.
Are you still working on the 5 x'' + x' + t x^3 = t + 3 u(x) just with a different range over which u(x) is 1?
Could you remind us what the boundary conditions are?
options = odeset('Events', @velocityEventsFcn);
[t, x, te, xe, ie] = ode23s(@odefcn, [0 10], [-0.5 1e-5], options);
plot(t, x, 'linewidth', 1.5)
legend({"x'", "x''"})

function dxdt = odefcn(t, x)
dxdt = zeros(2, 1);
u = x(1)>=0 && x(1)<=10^-9;
dxdt(1) = x(2);
dxdt(2) = (t + 3*u - (x(2) + t*x(1)^3))/5; % 5*x" + x' + t*x^3 = t + 3*u(x)
end
function [position, isterminal, direction] = velocityEventsFcn(t, x)
position = x(2); % When velocity x(2) = 0,
isterminal = 1; % the integration stops,
direction = 0; % and the velocity cannot go into negative no matter what
end
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
