HI im kind of new to Matlab. What is the problem with my code displaying the error "Index exceeds the number of array elements (0)."

1 view (last 30 days)
load database
D=[];
for (i=1:size(F,1))
d=sum(abs(F(i)-f))
D=[D d];
end
  1 Comment
Stephen23
Stephen23 on 21 Jan 2021
Edited: Stephen23 on 21 Jan 2021
This could happen if F has zero columns and non-zero rows:
F = nan(3,0);
i = size(F,1);
F(i)
Index exceeds the number of array elements (0).

Sign in to comment.

Answers (1)

Hernia Baby
Hernia Baby on 24 Feb 2021
You will see F value on the work space.
As Stephen Cobeldick says, F may have zero columns and non-zero rows.

Community Treasure Hunt

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

Start Hunting!