MATLAB: Invalid index into an array of size {6, 22} with 132.

custom componentSimscape

I have implement a custom component with some parameters. One of them is a
DxMap = [0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98;
0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98;
0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98;
0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98;
0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98;
0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98 0.98];
And some inputs:
inputs
zTerrain = { [0, 0, 0], '1'}; % zTerrain : left
wkette = { 0, 'rad/s'}; % wkette:left
% [soilType; soilState; frAdd]
soilInfo = {[1; 1; 0], '1'}; % soilInfo : left
end
My equation section looks like:
equations
z.der == HLZ.v;
let
soilType = soilInfo(1);
soilState = soilInfo(2);
Dx = DxMap(soilState, soilType);
in
end
end
The Dx = DxMap(soilState, soilType); assigment gives me the error message: Invalid index into an array of size {6, 22} with 132.
Working with constant indices for soilState and soilType is working, but this is not what I want to do. They have to be input values.
Can anyone tell me, what's going wrong here?

Best Answer

This might be because you are assigning first element of soilInfo (which is a matrix) to soiltype and second element (which is a character) to soliState.
% [soilType; soilState; frAdd]
I assume from this comment that soilType and soilState are first and second elements of the matrix [1;1;0] in soilInfo. You may define soilType and soilState as
soilType = soilInfo{1}(1);
soilState = soilInfo{1}(2);
Also use soilType and soilState values such that they are less than 6 and 22 respectively for DxMap matrix defined above