my cord for ordinary differential equation didn't work

조회 수: 2 (최근 30일)
jongil park
jongil park 2021년 4월 3일
답변: Star Strider 2021년 4월 3일
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;

채택된 답변

Star Strider
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개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by