Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Alice Bobbi
Alice Bobbi le 30 Nov 2023
Modifié(e) : Rena Berman le 5 Déc 2023
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 commentaires
Alice Bobbi
Alice Bobbi le 30 Nov 2023
Modifié(e) : Alice Bobbi le 30 Nov 2023
I didn't, thank you.
Rena Berman
Rena Berman le 5 Déc 2023
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 30 Nov 2023
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 commentaires
Alice Bobbi
Alice Bobbi le 30 Nov 2023
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 le 30 Nov 2023
I should not have deleted my comment, lol.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by