dsolve problem not showing result
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Raghuraman S
am 14 Feb. 2019
Bearbeitet: madhan ravi
am 14 Feb. 2019
I was trying to solve a simple diffrential equation solving dy/dx =y/x and plot curves using different initial value conditions.
Please refer attached picture file, the script throws erros, where as the dsolve function in the command prompt gives the right answer. Matlab code is attached as well. When I change dy/dx = cos(x) or y+x even script works fine.
Sure,I am missing something, usual some help is appreciated.
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 14 Feb. 2019
Bearbeitet: madhan ravi
am 14 Feb. 2019
syms y(x)
eqn = diff(y) == y/x;
vars = y(x);
V = odeToVectorField(eqn)
M = matlabFunction(V,'vars', {'x','Y'})
interval = [0 pi]; %x interval
for y0=-3:4 %initial conditions
[x,ysol]=ode45(M,interval,y0);
plot(x,ysol)
hold on
end
grid on
ysol
2 Kommentare
madhan ravi
am 14 Feb. 2019
Just convert your symbolic ode to numerical ode and then plot the solutions.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!