MATLAB/Simulink accuse me of logical indexing when I am not trying to logically index

1 Ansicht (letzte 30 Tage)
I was editing a Simulink model and tried to build. One of the embedded MATLAB functions (proprietary code from our lab software) threw an error :
'Logical indexing requires support of variable-sized arrays, which is currently disabled. Function 'Show_Target/Embedded MATLAB Function' (#150.3475.3480), line 107, column 33: "state"'
Note that line numbers are different here because I removed parts of the code you don't need to see. The reference to 'state' in question are the ones in the 'for ii = 1:num_targets' loop at the bottom of the snippet.
The input state_in is an int8, stateindices is a 5x11 matrix of doubles. target is a 1x25 matrix of doubles.
So far as I can tell, there is no logical indexing in the statement
fill_colour_col = stateindices(state(ii), 1);
So I am confused by the error message. This code has worked every time I have compiled this task until now, and I did not mess with the proprietary code.
function VCODE = fcn(target, state_in, target_type, opacity_in, target_display, x_index, y_index, num_states, stateindices)
num_targets = size(target, 1);
if num_targets == length(state_in)
state = reshape(state_in, num_targets, 1);
else
state = state_in(1) * ones(num_targets, 1);
end
VCODE = zeros(num_targets, 70);
VCODE(:, 1) = target_type;
VCODE(:, 3) = target(:, x_index) * 0.01;
VCODE(:, 4) = target(:, y_index) * 0.01;
for ii = 1:num_targets
%IMPORTANT PART THAT THREW ERROR:
fill_colour_col = stateindices(state(ii), 1);
stroke_colour_col = stateindices(state(ii), 2);
stroke_width_col = stateindices(state(ii), 3);
%Function proceeds after this, the statements directly above inside the for loop are what threw the error.
  4 Kommentare
Margaret Schrayer
Margaret Schrayer am 3 Dez. 2020
Thank you both. I already checked the input type and verified that ii is not overwritten in the rest of the code, and the problem still persists.
Stephen23
Stephen23 am 3 Dez. 2020
@Margaret Schrayer: please upload the complete code and the required variables (in one mat file).

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by