I keep getting an error that says "unrecognized function or variable 'tspan'
3 views (last 30 days)
Show older comments
% 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');
0 Comments
Answers (1)
KSSV
on 6 Dec 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);
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!