Solving First order ODE with constant coefficient
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How do i fix y= sym('y(t)') as it always show error and could not run the program properly.
%%Solving First Order ODEs with constant coefficients
syms t s Y
y = syms('y(t)'); % writing y as a function of t
y1 = diff(y,t); % Derivative of y(t) in symbolic form
a = input('Enter the coefficient of dy/dt in the equation');
b = input('Enter the coefficient of y in the equation');
f = input('Enter the inhomogenous part of the equation');
y0 = input('The initial condition is y(0)-');
eqnt = a*y1 + b*y - f; % Differential equation in the form eqnt - 0
eqns = laplace (eqnt, s); %Taking Laplace Transform of the DE
eqns = subs(eqns, {'laplace (y(t), t,s)','y(0)'}, {Y,y0});
Y = simplify (solve(eqns, Y)); %Solving algebraic equation eqns - 0 for Y and simplifying
y = ilaplace (Y, s, t); %Taking inverse laplce transform of Y to get y
disp(['The solution of the differential equation is: y(t)', char(y)])
0 comentarios
Respuestas (1)
Bjorn Gustavsson
el 1 de Ag. de 2021
Editada: Bjorn Gustavsson
el 1 de Ag. de 2021
Should be as simple as:
sym y(t)
Also: isn't direct use of dsolve enough for you?
HTH
0 comentarios
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!