Clear Filters
Clear Filters

Index in position 1 exceeds array bounds (must not exceed 1) error for a function definition when I run a code in DDE-BIFTOOL

2 views (last 30 days)
Hi there, I am working in DDEBIFTOOL and I am running a code to plot a bifurctaion diagram. When I hit run in the code, MATLAB gives me the error "Index in position 1 exceeds array bounds (must not exceed 1)" referencing the first line in the funciton defintion (as in bold below):
HollingTanner_rhsSB1c=@(xx,par)[...
(par(1)*xx(2,1)) + (par(1)*xx(2,2)*exp(-par(2)*par(4))) - (par(2)*xx(1,1));....
(par(1)*xx(2,2)*exp(-par(2)*par(4))) - (par(3)*xx(2,1))];
I have done loads of research on this error, but I just cannot see where the problem is in the defintio of this function, given that I have used this code for this funciton in other simulations and it works perfectly.
I am very grateful for any help!

Answers (1)

Sourabh Kondapaka
Sourabh Kondapaka on 2 Sep 2020
Hi,
As you mentioned that the same function was working earlier as intended, I suspect the issue in your current use-case is with the input that is being passed.
It could be that the value that is being passed to the first parameter has only 1 row and inside the function the second row is being accessed, as follows , “xx(2,1)”
Below code is a much a simpler example which throws the same error as yours.
%% Has 1 row and 2 columns.
a = zeros(1,2);
%% Accessing the second row first index which is out of bounds.
disp(a(2,1));
Hence throws a similar error to yours:
Index in position 1 exceeds array bounds (must not exceed 1)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!