Ode45, Events error: SWITCH expression must be a scalar or a character vector
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have this problem using "Events" option for ode45.
In the main I have:
Tol0 = 1e-13;
Tol1 = 1e-13;
options = odeset('Events', @myEvent, 'RelTol', Tol0, 'AbsTol', Tol1);
s0 = [1, 2, 3, 4, 5, 6];
tspan = [0 100];
[time,S] = ode45('Dyn', tspan, s0, options);
My event function is:
function [value, isterminal, direction] = myEvent(t,S)
value = S(2);
isterminal = 1;
direction = 0;
end
The error appearing in the command window is:
SWITCH expression must be a scalar or a character vector.
Error in odeevents (line 34)
switch lower(eventFcn)
Error in ode45 (line 137)
odeevents(odeIsFuncHandle,ode,t0,y0,options,varargin);
Error in Main (line 31)
[time,S] = ode45('Dyn', tspan, s0, options);
Could you help me?
Thank you.
3 个评论
回答(1 个)
Walter Roberson
2023-11-30
I have seen this before when the person had a third-party version of lower in their MATLAB path. Please show
which -all lower
The interfering toolbox was something like EEGLab or SPM12 or something-or-other-8 (I forget the name)
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!