my cord for ordinary differential equation didn't work
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 3 Apr 2021
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 Comments
More Answers (0)
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!