matcont ode45 Unrecognized property name 'NonNegative' error

I am trying to use matcont on mac on R2023a Version of Matlab. Already installed Xcode.
The GUI opens normal, but everytime I am trying to Compute a ODE System it gets the error.
Unrecognized property name 'NonNegative'. See ODESET for possibilities.
If I run which -all odeset I also get 2 path:
1) Code/Matlab/MatCont7p4/Continuer/odeset.m
2) /Applications/MATLAB_R2023a.app/toolbox/matlab/funfun/odeset.m
Does anybody know how to fix this problem?

7 Comments

The first "odeset.m" file is from the matcont package that I downloaded from https://sourceforge.net/projects/matcont/.
I renamed the file from the matcont-package to "odeset_matcont.m" and run "matcont" again.
Now I get the error: "Unrecognized property name 'Hessians'."
I did not know that the first "odeset.m" belongs to another code package.
I don't know what is best to handle the conflict in this case.
Okai, still thank you so for fory trying.
Somewhere in your code you use with matcont, you seem to use the odeset option "NonNegative". As you found out by yourself, this option is not available in matcont. So remove this choice of option "NonNegative" in your code (and rename "odeset.m" from matcont to its original name).
I am just running "matcont" in the Matlab-terminal and then proceed with using the Matcont-GUI.
And there I do not specify an option of "Nonnegative". It is also not possible to specify anything regarding NonNegative there.
Also I compared the implementation of odeset.m in base Matlab and matcont and they seem to be exactly the same EXCEPT base-matlab has a NonNegative Option that matcont-odeset does NOT have.
So somehere there may lie the problem?
What is your code you want to run with "matcont" ?
Look through it and make sure you don't use the "NonNegative" option.
That's still the only explanation I can think of that could make the two softwares come into conflict.
I am trying to simulate any of the ODE-Systems that are already implemented in the matcont-package. Trying out all different ODE-Syystem leads to the same error.
I then tried to define a new simple ODE-System that contains a simple saddle_node bifurcation to test matcont.
I implemented this in the matcont-Gui which then generates Matlab "sad_node.m" code.
In the matlab code sad_node.m the function "odeset" is used in the the 3 section of the following code:
Do I have to change some input of odeset() ? Because I did not specify NonNegative nowhere.
function out = sad_node_test
out{1} = @init;
out{2} = @fun_eval;
out{3} = @jacobian;
out{4} = @jacobianp;
out{5} = @hessians;
out{6} = @hessiansp;
out{7} = @der3;
out{8} = [];
out{9} = [];
% --------------------------------------------------------------------------
function dydt = fun_eval(t,kmrgd,par_r)
dydt=[par_r+kmrgd(1)^2;];
% --------------------------------------------------------------------------
function [tspan,y0,options] = init
handles = feval(sad_node_test);
y0=[0];
options = odeset('Jacobian',handles(3),'JacobianP',handles(4),'Hessians',handles(5),'HessiansP',handles(6));
tspan = [0 10];
% --------------------------------------------------------------------------

Sign in to comment.

 Accepted Answer

This was Solution from Hil Meijer that worked for me:
"As I wrote above (as MatCont developer!), and probably the culprit of this problem, here is a quick fix: In the file MatCont7p3/Continuer/odeget.m, you can add a line (say at line 63, keeping alphabetical order) with the entry:
'NonNegative '
After that, on my machines, simulations again work."

More Answers (1)

Hi Simon,
As per my understanding, the error you encountered regarding the 'NonNegative' property in MatCont is likely due to a conflict between the odeset function provided by MatCont and the built-in odeset function in MATLAB.
To resolve this issue, you can try the following steps:
1. Open the file `Code/Matlab/MatCont7p4/Continuer/odeset.m` in a text editor.
2. Search for the line that includes the property 'NonNegative' and comment it out by adding a '%' at the beginning of the line. It should look something like this:
MATLAB Code -
% options = optimset(options, 'NonNegative', 1:neq);
3. Save the modified `odeset.m` file.
By commenting out the line that sets the 'NonNegative' property, you are effectively disabling that specific property in MatCont.
After making this change, try running the MatCont GUI again and computing the ODE system. The error related to the 'NonNegative' property should no longer appear.
Please note that modifying the source code of MatCont is not an ideal solution and may have implications for the functionality and behavior of the software. Therefore, it's recommended to proceed with caution and test the modified MatCont to ensure it works as expected.
I hope this helps resolving the issue.

3 Comments

Hello Shishir,
thank you for the fast reply, but I seem not to find the "NonNegative" Option in the code of "odeset.m"-file of Matcont.
Is it possible that the basefunction of odeset in Matlab is the problem?
Below I will post the Macont Code of odeset.m
----------------------------------------------------------------
function options = odeset(varargin)
%ODESET Create/alter ODE OPTIONS structure.
% OPTIONS = ODESET('NAME1',VALUE1,'NAME2',VALUE2,...) creates an
% integrator options structure OPTIONS in which the named properties have
% the specified values. Any unspecified properties have default values.
% It is sufficient to type only the leading characters that uniquely
% identify the property. Case is ignored for property names.
%
% OPTIONS = ODESET(OLDOPTS,'NAME1',VALUE1,...) alters an existing options
% structure OLDOPTS.
%
% OPTIONS = ODESET(OLDOPTS,NEWOPTS) combines an existing options structure
% OLDOPTS with a new options structure NEWOPTS. Any new properties
% overwrite corresponding old properties.
%
% ODESET with no input arguments displays all property names and their
% possible values.
%
%ODESET PROPERTIES
%
%RelTol - Relative error tolerance [ positive scalar {1e-3} ]
% This scalar applies to all components of the solution vector, and
% defaults to 1e-3 (0.1% accuracy) in all solvers. The estimated error in
% each integration step satisfies e(i) <= max(RelTol*abs(y(i)),AbsTol(i)).
%
%AbsTol - Absolute error tolerance [ positive scalar or vector {1e-6} ]
% A scalar tolerance applies to all components of the solution vector.
% Elements of a vector of tolerances apply to corresponding components of
% the solution vector. AbsTol defaults to 1e-6 in all solvers.
%
%Refine - Output refinement factor [ positive integer ]
% This property increases the number of output points by the specified
% factor producing smoother output. Refine defaults to 1 in all solvers
% except ODE45, where it is 4. Refine doesn't apply if length(TSPAN) > 2.
%
%OutputFcn - Name of installable output function [ string ]
% This output function is called by the solver after each time step. When
% a solver is called with no output arguments, OutputFcn defaults to
% 'odeplot'. Otherwise, OutputFcn defaults to ''.
%
%OutputSel - Output selection indices [ vector of integers ]
% This vector of indices specifies which components of the solution vector
% are passed to the OutputFcn. OutputSel defaults to all components.
%
%Stats - Display computational cost statistics [ on | {off} ]
%Jacobian - Jacobian function [ function | constant matrix ]
% Set this property to a function FJac (if FJac(t,y) returns dF/dy) or to
% the constant value of dF/dy.
%
%JConstant - Constant Jacobian matrix dF/dy [ on | {off} ]
% Set this property 'on' if the Jacobian matrix dF/dy is constant.
%
%JPattern - Jacobian sparsity pattern available from ODE file [ on | {off} ]
% Set this property 'on' if the ODE file is coded so F([],[],'jpattern')
% returns a sparse matrix with 1's showing nonzeros of dF/dy.
%
%Vectorized - Vectorized ODE file [ on | {off} ]
% Set this property 'on' if the ODE file is coded so that F(t,[y1 y2 ...])
% returns [F(t,y1) F(t,y2) ...].
%
%Events - Locate events [ on | {off} ]
% Set this property 'on' if the ODE file is coded so that F(t,y,'events')
% returns the values of the event functions. See ODEFILE.
%
%Mass - Mass matrix available from ODE file [ {none} | M | M(t) | M(t,y) ]
% Change this property from 'none' if the ODE file is coded so that
% F(t,[],'mass') returns a mass matrix. 'M' indicates a constant mass
% matrix, 'M(t)' indicates a time-dependent mass matrix, and 'M(t,y)'
% indicates a time- and state-dependent mass matrix.
%
%MassSingular - Mass matrix is singular [ yes | no | {maybe} ]
% Set this property to 'no' if the mass matrix is not singular.
%
%MaxStep - Upper bound on step size [ positive scalar ]
% MaxStep defaults to one-tenth of the tspan interval in all solvers.
%
%InitialStep - Suggested initial step size [ positive scalar ]
% The solver will try this first. By default the solvers determine an
% initial step size automatically.
%
%MaxOrder - Maximum order of ODE15S [ 1 | 2 | 3 | 4 | {5} ]
%
%BDF - Use Backward Differentiation Formulas in ODE15S [ on | {off} ]
% This property specifies whether the Backward Differentiation Formulas
% (Gear's methods) are to be used in ODE15S instead of the default
% Numerical Differentiation Formulas.
%
%NormControl - Control error relative to norm of solution [ on | {off} ]
% Set this property 'on' to request that the solvers control the error in
% each integration step with norm(e) <= max(RelTol*norm(y),AbsTol). By
% default the solvers use a more stringent component-wise error control.
%
% See also ODEGET, ODEFILE, ODE45, ODE23, ODE113, ODE15S, ODE23S.
% Mark W. Reichelt and Lawrence F. Shampine, 5/6/94
% Copyright (c) 1984-98 by The MathWorks, Inc.
% $Revision: 1.37 $ $Date: 1998/04/10 12:24:17 $
% Print out possible values of properties.
if (nargin == 0) & (nargout == 0)
fprintf(' AbsTol: [ positive scalar or vector {1e-6} ]\n');
fprintf(' BDF: [ on | {off} ]\n');
fprintf(' Events: [ function ]\n');
fprintf(' InitialStep: [ positive scalar ]\n');
fprintf(' Jacobian: [ matrix | function ]\n');
fprintf(' JacobianP: [ matrix | function ]\n');
fprintf(' Hessians: [ matrix | function ]\n');
fprintf(' HessiansP: [ matrix | function ]\n');
fprintf(' Der3: [ matrix | function ]\n');
fprintf(' Der4: [ matrix | function ]\n');
fprintf(' Der5: [ matrix | function ]\n');
fprintf(' JConstant: [ on | {off} ]\n');
fprintf(' JPattern: [ sparse matrix ]\n');
fprintf(' Mass: [ matrix | function ]\n');
fprintf(' MassSingular: [ yes | no | {maybe} ]\n');
fprintf(' MaxOrder: [ 1 | 2 | 3 | 4 | {5} ]\n');
fprintf(' MaxStep: [ positive scalar ]\n');
fprintf(' NormControl: [ on | {off} ]\n');
fprintf(' OutputFcn: [ function ]\n');
fprintf(' OutputSel: [ vector of integers ]\n');
fprintf(' Refine: [ positive integer ]\n');
fprintf(' RelTol: [ positive scalar {1e-3} ]\n');
fprintf(' Stats: [ on | {off} ]\n');
fprintf(' Vectorized: [ on | {off} ]\n');
fprintf('\n');
return;
end
Names = [
'AbsTol '
'BDF '
'Events '
'InitialStep '
'Jacobian '
'JacobianP '
'Hessians '
'HessiansP '
'Der3 '
'Der4 '
'Der5 '
'JConstant '
'JPattern '
'Mass '
'MassConstant' % grandfathered
'MassSingular'
'MaxOrder '
'MaxStep '
'NormControl '
'OutputFcn '
'OutputSel '
'Refine '
'RelTol '
'Stats '
'Vectorized '
];
[m,n] = size(Names);
names = lower(Names);
% Combine all leading options structures o1, o2, ... in odeset(o1,o2,...).
options = [];
for j = 1:m
eval(['options.' Names(j,:) '= [];']);
end
i = 1;
while i <= nargin
arg = varargin{i};
if ischar(arg) % arg is an option name
break;
end
if ~isempty(arg) % [] is a valid options argument
if ~isa(arg,'struct')
error(['Expected argument %d to be a string property name ' ...
'or an options structure\ncreated with ODESET.'], i);
end
for j = 1:m
if any(strcmp(fieldnames(arg),deblank(Names(j,:))))
val = getfield(arg, Names(j,:));
else
val = [];
end
if ~isempty(val)
options = setfield(options, Names(j,:), val);
end
%for future releases
% if any(strcmp(fieldnames(arg),deblank(Names(j,:))))
% deblank(Names(j,:))
% val= arg.deblank(Names(j,:)));
% else
% val = [];
% end
% if ~isempty(val)
% options.(deblank(Names(j,:)))= val;
% end
end
end
i = i + 1;
end
% A finite state machine to parse name-value pairs.
if rem(nargin-i+1,2) ~= 0
error('Arguments must occur in name-value pairs.');
end
expectval = 0; % start expecting a name, not a value
while i <= nargin
arg = varargin{i};
if ~expectval
if ~ischar(arg)
error('Expected argument %d to be a string property name.', i);
end
lowArg = lower(arg);
j = strmatch(lowArg,names);
if isempty(j) % if no matches
error('Unrecognized property name ''%s''.', arg);
elseif length(j) > 1 % if more than one match
% Check for any exact matches (in case any names are subsets of others)
k = strmatch(lowArg,names,'exact');
if length(k) == 1
j = k;
else
msg = sprintf('Ambiguous property name ''%s'' ', arg);
msg = [msg '(' deblank(Names(j(1),:))];
for k = j(2:length(j))'
msg = [msg ', ' deblank(Names(k,:))];
end
error('%s).', msg);
end
end
expectval = 1; % we expect a value next
else
options = setfield(options, Names(j,:), arg);
% options.(deblank(Names(j,:)))= arg;
expectval = 0;
end
i = i + 1;
end
if expectval
error('Expected value for property ''%s''.', arg);
end
Also here is a similar problem with matcont and the odeset.m code that is not answered:
https://de.mathworks.com/matlabcentral/answers/1944854-when-using-ode45-have-error-using-odeget-unrecognized-property-name-nonnegative-see-odeset-for
Based on the code you provided, it seems that the 'NonNegative' property is not present in the MatCont version of the `odeset.m` file. Therefore, the issue might not be related to the `odeset` function itself.
Since you have mentioned that you already installed Xcode, it's possible that the problem lies in the version of MATLAB or the compatibility between MATLAB and Xcode.
To troubleshoot this issue, you can try the following steps:
1. Ensure that you have the latest version of MATLAB and Xcode installed. Check for any available updates and install them if necessary.
2. Verify that the Xcode Command Line Tools are properly configured. Open Terminal and run the following command:
xcode-select --print-path
This should display the path to the Xcode Command Line Tools. If the path is not displayed or it's incorrect, you can set it using the following command:
sudo xcode-select --switch /Applications/Xcode.app
Replace `/Applications/Xcode.app` with the correct path to your Xcode installation.
3. Restart your computer to ensure any changes take effect.
4. Launch MATLAB and try running MatCont again to see if the issue persists.
I hope this resolves the issue, if the problem still occurs, you may need to reach out to the MatCont support or MATLAB MathWorks support for further assistance. They can provide more specific guidance and help you resolve the compatibility issue between MatCont and MATLAB on your macOS system.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!