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
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
built-in (/MATLAB/toolbox/matlab/strfun/lower) lower is a built-in method % string method /MATLAB/toolbox/parallel/parallel/@codistributed/lower.m % codistributed method
The interfering toolbox was something like EEGLab or SPM12 or something-or-other-8 (I forget the name)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by