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!