ODE with goniometric function
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, how can I solve and plot this ODE: 1*y''+23.25*(2.5*sin(x+1.5))*y'=0
there is my code:
eqn = '1*D2y+23.25*(2.5*sin(x+1.5))*D1y = 0';
inits = 'y(0)=0.7, Dy(0)=6.2';
y=dsolve(eqn,inits,'x')
ezplot(y, [-1 10])
Thank you so much
0 commentaires
Réponses (1)
Star Strider
le 10 Avr 2018
This works in R2018a, although it gives a ‘Warning’ about array inputs:
syms x y(x)
D1y = diff(y);
D2y = diff(D1y);
eqn = D2y+23.25*(2.5*sin(x+1.5))*D1y == 0;
inits = [y(0)==0.7, D1y(0)==6.2];
y=dsolve(eqn,inits)
Y = matlabFunction(y)
ezplot(Y, [-1 10])
This assumes that ‘y’ is a function of ‘x’. If both ‘x’ and ‘y’ are functions of another variable, we need to know.
2 commentaires
Star Strider
le 11 Avr 2018
In R2018a the matlabFunction call produces:
Y =
function_handle with value:
@(x)exp(cos(3.0./2.0).*(-4.65e2./8.0)).*integral(@(y)exp(cos(y+3.0./2.0).*(4.65e2./8.0)),0.0,x).*(3.1e1./5.0)+7.0./1.0e1
or, more conveniently:
Y = @(x) exp(cos(3.0./2.0).*(-4.65e2./8.0)).*integral(@(y)exp(cos(y+3.0./2.0).*(4.65e2./8.0)),0.0,x).*(3.1e1./5.0)+7.0./1.0e1;
however only this construction appears to work:
Y = @(x) exp(cos(3.0./2.0).*(-4.65e2./8.0)).*integral(@(y)exp(cos(y+3.0./2.0).*(4.65e2./8.0)),0.0,x,'ArrayValued',1).*(3.1e1./5.0)+7.0./1.0e1;
X = linspace(-1, 10);
Yv = arrayfun(Y, X);
figure
plot(X, Yv)
grid
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!