Info

This question is closed. Reopen it to edit or answer.

Why this error message? Subscript indices must either be real positive integers or logicals.

2 views (last 30 days)
Why do i get this error message
Subscript indices must either be real positive integers or logicals.
for i = 1:numel(matrix_a)
handles.index_a = matrix_a(i)
handles.index_b = matrix_b(i)
for somthin
[u v] = function(var_u(handles.index_a, handles.index_b)var_v(handles.index_a, handles.index_b))
end
end
pls help

Answers (1)

the cyclist
the cyclist on 25 Aug 2014
Just a guess, but ...
You are using handles.index_a and handles.index_b as indices into var_u and var_v. Because handles.index_a traces back to matrix_a, I am guessing that matrix_a (or b) has some entries that are not positive integers, and therefore cannot be used as an index.
  4 Comments
the cyclist
the cyclist on 25 Aug 2014
There is a conceptual error in your code, that I don't think we can fix for you. If the first column of matrix_a has a zero, then it cannot be an index. The code simply needs to be rewritten such that you really only access the indices you want.

Community Treasure Hunt

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

Start Hunting!