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

5 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Sai Sri Pathuri
Sai Sri Pathuri il 9 Lug 2020
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 Commento
Marco Lehmann
Marco Lehmann il 9 Lug 2020
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Foundation and Custom Domains in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by