Ode45, Events error: SWITCH expression must be a scalar or a character vector

조회 수: 2 (최근 30일)
Alice Bobbi
Alice Bobbi 2023년 11월 30일
편집: Rena Berman 2023년 12월 5일
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
Alice Bobbi
Alice Bobbi 2023년 11월 30일
편집: Alice Bobbi 2023년 11월 30일
I didn't, thank you.

댓글을 달려면 로그인하십시오.

답변 (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)
  댓글 수: 2
Alice Bobbi
Alice Bobbi 2023년 11월 30일
Thank you but the error was another one. If the option Events is used, I have to recall the integrated function as @Dyn, not 'Dyn'.
Dyuman Joshi
Dyuman Joshi 2023년 11월 30일
I should not have deleted my comment, lol.

댓글을 달려면 로그인하십시오.

카테고리

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