I have been doing array indexing as follows
>> n=[1 2 3]
n =
1 2 3
>> idx=1
idx =
1
>> n([idx+1 idx])
ans =
2 1
without any problem. However, today I encounter this error in my following snippet. Please forgive me. I understand I should provide MWE, but I simply cannot reproduce the error!
>> %%% interpret tree
bitmap = zeros(pix_no_per_side, pix_no_per_side);
x_pixels = 1:1:pix_no_per_side;
y_pixels = 1:1:pix_no_per_side;
rule_set = {}; % cell to accommodate rows of diff. sizes
% parse branches
trav_iter = tr.depthfirstiterator;
while tr.get(trav_iter(end)) <= 0 % still have branch unparsed
branch = [1]; % contains the root
node_idx = 1;
while tr.get(branch(end)) > 0 % not bottom yet
node_idx = node_idx+1;
branch = [branch trav_iter(node_idx)];
end
rule_set{end+1} = branch; % one rule per cell
disp(node_idx) % DISPLAYING FOR DEBUGGING
if numel(rule_set) == 1 % only one branch found so far
trav_iter(node_idx) = []; % remove this leaf
else % more than one branches found so far
trav_iter([node_idx-1 node_idx]) = []; % remove this leaf and parent node
end
end
3
3
2
Subscript indices must either be real positive integers or logicals.
>>