my cord for ordinary differential equation didn't work

2 visualizzazioni (ultimi 30 giorni)
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;

Risposta accettata

Star Strider
Star Strider il 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.
.

Più risposte (0)

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by