eq(t) =
Problem making it past line 8 - no error given
古いコメントを表示
Im currently running into an issue once I hit line eight where it refuses to move past that point and im unsure as to why as it doesnt give an error, freeze, or crash. It just indefinetly keeps loading on that line. Im using release R2026a and have tried it in a previous 2025 version as well and had the same issue. Any help / explanation on how to fix it is welcome. Thanks in advance!
syms y(t)
eq = 8*diff(y, t, 3) - diff(y, t) == cos(20*t) + sin(2*t)
cond = [y(10) == 50, subs(diff(y), t, 0) == 0, subs(diff(y, t, 2), t, 0) == 0]
solone = dsolve(eq, cond)
cond2 = [y(10) == 15, subs(diff(y), t, 0) == 0, subs(diff(y, t, 2), t, 0) == 3]
soltwo = dsolve(eq, cond2)
trange = linspace(-10, 20, 1000);
y1 = subs(solone, t, trange)
y2 = subs(soltwo, t, trange)
hold on
figure
plot(trange, y1, 'b-', 'LineWidth', 1)
plot(trange, y2, 'r:', 'LineWidth', 1)
hold off
xlabel('time = t');
ylabel('y(t)')
title('solution of the equation')
ylim([-150 200])
legend('y(10)=50, y''(0)=0, y''''(0)=0', 'y(10)=15, y''(0)=0, y''''(0)=3')
採用された回答
その他の回答 (1 件)
Walter Roberson
約22時間 前
It is not taking a long time to compute the symbolic solution at each t: it is taking a long time to display the symbolic solution at each t.
You coded
y1 = subs(solone, t, trange)
which does not end in a semi-colon, so it is a request to display all 1000 symbolic results.
2 件のコメント
Paul
約3時間 前
Good point. As usual.
syms y(t)
eq = 8*diff(y, t, 3) - diff(y, t) == cos(20*t) + sin(2*t)
cond = [y(10) == 50, subs(diff(y), t, 0) == 0, subs(diff(y, t, 2), t, 0) == 0]
solone = dsolve(eq, cond)
cond2 = [y(10) == 15, subs(diff(y), t, 0) == 0, subs(diff(y, t, 2), t, 0) == 3]
soltwo = dsolve(eq, cond2)
trange = linspace(-10, 20, 1000);
y1 = subs(solone, t, trange);
y2 = subs(soltwo, t, trange);
figure
plot(trange, y1, 'b-', 'LineWidth', 1)
hold on
plot(trange, y2, 'r:', 'LineWidth', 1)
hold off
xlabel('time = t');
ylabel('y(t)')
title('solution of the equation')
ylim([-150 200])
legend('y(10)=50, y''(0)=0, y''''(0)=0', 'y(10)=15, y''(0)=0, y''''(0)=3')
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







