I keep getting an error that says "unrecognized function or variable 'tspan'
Afficher commentaires plus anciens
% close by initial condition
Y0 = [0;1.001];
epsilon = 8.53;
F = 1.2;
Tdr = 10;
% ODE solving
[t3,y3] = ode23(@(t,y)VanDerPolEq2(t,y,epsilon,F,Tdr),tspan,Y0);
% plotting
figure();
plot(t2,y2(:,1),'r-','LineWidth',1.0); xlabel('t'); ylabel('x1');
title('x1 vs. t for x1(0) = 0, x2(0) = 1, F = 1.2, Tdr = 10, epsilon = 8.53');
figure();
plot(t3,y3(:,1),'r-','LineWidth',1.0); xlabel('t'); ylabel('x1');
title('x1 vs. t for x1(0) = 0, x2(0) = 1.001, F = 1.2, Tdr = 10, epsilon = 8.53');
figure();
plot(t2,abs(y3(:,1)-y2(:,1)), 'k-', 'LineWidth', 1.0); xlabel('t'); ylabel('absolute difference');
title('absolute difference vs time');
figure();
plot(t2,log(abs(y3(:,1)-y2(:,1))), 'k-', 'LineWidth', 1.0); xlabel('t'); ylabel('log of absolute difference');
title('log of absolute difference vs time');
Réponses (1)
KSSV
le 6 Déc 2021
You need to provide the time for which you want to integrate your ode. Call the function something like below:
[t3,y3] = ode23(@(t,y)VanDerPolEq2(t,y,epsilon,F,Tdr),[0 10],Y0);
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!