Invalid index into an array of size {6, 22} with 132.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Marco Lehmann
le 6 Juil 2020
Commenté : Walter Roberson
le 19 Août 2024
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?
1 commentaire
Walter Roberson
le 19 Août 2024
I wonder if inside SimScape, indexes start from 0? If so then you might need
soilType = soilInfo(1) - 1;
soilState = soilInfo(2) - 1;
Réponse acceptée
Sai Sri Pathuri
le 9 Juil 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
2 commentaires
Felix
le 19 Août 2024
@Sai Sri Pathuri This answer is wrong. This is not Matlab, but Simscape language. soilInfo is not a cell array. The '1' just indicates that the input is unit-less.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Composite Components dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!