eq(t) =
Problem making it past line 8 - no error given
Ältere Kommentare anzeigen
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')
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 16 Sep. 2026 um 1:32
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 Kommentare
Paul
am 16 Sep. 2026 um 1:41
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')
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







