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

조회 수: 5 (최근 30일)
Marco Lehmann
Marco Lehmann 2020년 7월 6일
댓글: Marco Lehmann 2020년 7월 9일
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?

채택된 답변

Sai Sri Pathuri
Sai Sri Pathuri 2020년 7월 9일
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
  댓글 수: 1
Marco Lehmann
Marco Lehmann 2020년 7월 9일
I'm now using a simple tablelookup
Dx = tablelookup(soilStates, soilTypes, DxMap, soilType, soilState, interpolation=linear, extrapolation=nearest) in my euatiions block instead of Dx = DxMap(soilState, soilType).
This is working well.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Foundation and Custom Domains에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by