Laplace with Heaviside step function solving with ode45
Afficher commentaires plus anciens
I dont understand why I keep getting an error, can you please explain to me why and how I can fix this?
syms s t Y
f = heaviside(t-1)- heaviside(t-2);
X = laplace(f);
Sol = X ./(s^2+3*s+2);
sol = symfun(ilaplace(Sol),t);
pretty(sol)
tspan = [0 5];
ic = [0 0];
fn = @(t,Y) [Y(2); (heaviside(t-1)- heaviside(t-2) - 3*Y(2) - 2* Y(1))];
[t,Y] = ode45(fn,tspan,ic);
hold on
plot(t,y(:,1))
fplot(sol, [0 5])
grid on
xlabel('x')
ylabel('y')
legend('Ode45' ,'Solved' )
hold off
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Simulation, Tuning, and Visualization dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!