my cord for ordinary differential equation didn't work
조회 수: 2 (최근 30일)
이전 댓글 표시
hi. i just entered ordinary differential equation for analysising for damping by coulomb friction.
but it didn't work. just start, and happened nothing. i tried to find where is wrong, but i couldn't.
can you help me?
that is my code.


tspan = [0: 0.05: 8];
x0 = [0.4; 0.0];
[t,x] = ode23('dfuncl', tspan, x0);
plot (t, x(:, 1));
xlabel ('t');
ylabel ('x(t)');
%dfuncl.m
function f = dfuncl(t,x)
f = zeros(2,1);
f(1) = x(2);
f(2) = -0.5 * 9.81 * sign(x(2)) - 100 * x(1) / 5;
댓글 수: 0
채택된 답변
Star Strider
2021년 4월 3일
Try this instead:
tspan = [0: 0.05: 8];
x0 = [0.4; 0.0];
[t,x] = ode15s(@dfuncl, tspan, x0);
figure
plot (t, x(:, 1));
xlabel ('t');
ylabel ('x(t)');
%dfuncl.m
function f = dfuncl(t,x)
f = zeros(2,1);
f(1) = x(2);
f(2) = -0.5 * 9.81 * sign(x(2)) - 100 * x(1) / 5;
end
The differential encounters a singularity and throws this Warning:
Warning: Failure at t=7.022881e-01. Unable to meet integration tolerances without reducing the
step size below the smallest value allowed (1.776357e-15) at time t.
.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!