matlab ode45 error

2 vues (au cours des 30 derniers jours)
Saptarshi Bhattacharjee
Saptarshi Bhattacharjee le 5 Fév 2019
Commenté : madhan ravi le 6 Fév 2019
tspan= linspace(0,0.1,1);
yinit = [0.5 , 0.8];
[t,y] = ode45(@maths(t,y), tspan, yinit) --->error invalid expression,use parenteses,mismatched delimiters??
plot(t,y(:,1),'-o');
xlabel("x values");
ylabel("y values");
plot(t,y(:,2),'-.');
plot(t,y(:,1),'-o',t,y(:,2),'-.');
plot(y(:,1),y(:,2));
plot(y(:,2),y(:,1));

Réponse acceptée

madhan ravi
madhan ravi le 5 Fév 2019
[t,y]=ode45(@maths,...)
  3 commentaires
madhan ravi
madhan ravi le 6 Fév 2019
Saptarshi Bhattacharjee's answer moved here:
After correcting the original code, I get different graphs with different number of points in linspace and different graphs with different values of yinit .So my doubt is : is this a limitation of ode45 or is it because ode45 is a numerical method?
madhan ravi
madhan ravi le 6 Fév 2019
It's always a good idea to read the documentation changing the tspan with intermediate points may change the solution. So the best idea is to just define the start point and the end point and let the solver evaluate with it's default step size. yinit is the starting point where the solution begins (initial condition). Please refer https://www.mathworks.com/help/matlab/ref/ode45.html#bu00_4l_sep_shared-tspan which explains it clearly.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by