Dot indexing is not supported for variables of this type.
Show older comments
I got this error : Dot indexing is not supported for variables of this type.
I will show you the line of code where its happening:
function [equations] = analyserNoeud(this, indiceNoeud, equations)
forcesExternesX = [];
forcesExternesY = [];
forceAppuisX = [];
forceAppuisY = [];
forcesNoeud = [];
normeX = 0;
normeY = 0;
noeudCourant = this.getNoeud(indiceNoeud);
indiceNoeudConnecte = this.getConnectionIemeNoeud(indiceNoeud);
for i = 1:size(indiceNoeudConnecte, 2)
indiceVoisin = indiceNoeudConnecte(i);
voisin = this.getNoeud(indiceVoisin);
forceCourante = Force(noeudCourant, voisin);
forcesNoeud = [forcesNoeud, forceCourante];
end
%%%%%%This part that make the error Dot indexing is not supported for variables of this type.
%%%%Error in Treillis/analyserNoeud (line 214)
%%% this.getForcesReactionsIemeNoeud(indiceNoeud).getForceX(), ...
forcesX = [forcesNoeud.getForceX(),...
this.getForcesReactionsIemeNoeud(indiceNoeud).getForceX(), ...
this.getForcesExternesIemeNoeud(indiceNoeud).getForceX()];
forcesY = [forcesNoeud.getForceY(),...
this.getForcesReactionsIemeNoeud(indiceNoeud).getForceY(), ...
this.getForcesExternesIemeNoeud(indiceNoeud).getForceY()];
[inconnuesX, equationX, resultante1] = forcesX.somme();
[inconnuesY, equationY, resultante2] = forcesY.somme();
equations.ajouterEquation(inconnuesX, equationX, ...
-resultante1.getComposanteX());
equations.ajouterEquation(inconnuesY, equationY, ...
-resultante2.getComposanteY());
end
and also this one
for i = 1: this.getNbNoeud()
[equations] = this.analyserNoeud(i, equations); %this line make the error
end
end
function [equations] = analyserNoeud(this, indiceNoeud, equations)
You could check the entire program in attachment.
3 Comments
Geoff Hayes
on 7 Apr 2020
Charles-Antoine - I think that you need to post the full error message for each of your two cases where there are errors. Also, it is a little challenging trying to run and step through your code without knowing what the inputs are and (probably) missing code for some of the calls within this class. For example, you say
[equations] = this.analyserNoeud(i, equations); %this line make the error
but is it really that line that generates the error or is there an error somewhere in analyserNoeud?
Charles-Antoine Danis
on 7 Apr 2020
Charles-Antoine Danis
on 7 Apr 2020
Edited: Charles-Antoine Danis
on 7 Apr 2020
Answers (1)
Geoff Hayes
on 7 Apr 2020
Charles-Antoine - it seems that it is the same line that is causing the problem
this.getForcesReactionsIemeNoeud(indiceNoeud).getForceX(), ...
forcesX = [forcesNoeud.getForceX(),...
this.getForcesReactionsIemeNoeud(indiceNoeud).getForceX(), ...
this.getForcesExternesIemeNoeud(indiceNoeud).getForceX()];
and then run your app. When the debugger pauses at this line, evaluate (in the command window since in debug "mode")
this.getForcesReactionsIemeNoeud(indiceNoeud)
Did this evaluate successfully or did it generate the error? If the error, then there is something incorrect about your assumptions concerning the this object. If there is no error, then what is
this.getForcesReactionsIemeNoeud(indiceNoeud)
? Is it a struct or an object? If neither of those things then it could be that the problem/error is with the getForcesReactionsIemeNoeud method. If you look closely at the method
function [forceReactionIemeNoeud] = getForcesReactionsIemeNoeud(this,indiceNoeud)
Constantes;
forceReactionIemeNoeud = [];
typeAppui = this.noeuds(indiceNoeud).getTypeAppui();
if (typeAppui == SANS_APPUI)
Force.empty(1,0);
else
forceReactionY = Force();
nomForceY = sprintf('Fr%gy',indiceNoeud);
forceReactionY.setNom(nomForceY);
position = getPosition(this.noeuds(indiceNoeud));
forceReactionY.setPointAction(position);
forceReactionY.setOrientation(pi/2);
forceReactionIemeNoeud = [forceReactionIemeNoeud,forceReactionY];
if(typeAppui == GOUPILLE || typeAppui == ENCASTREMENT)
forceReactionX = Force();
nomForceX = sprintf('Fr%gx',indiceNoeud);
forceReactionX.setNom(nomForceX);
forceReactionX.setOrientation(0);
forceReactionX.setPointAction(position);
forceReactionIemeNoeud = [forceReactionX,forceReactionIemeNoeud];
elseif(typeAppui == ENCASTREMENT)
momentReaction = Force();
nomMoment = sprintf('Fr%gm',indiceNoeud);
momentReaction.setNom(nomMoment);
momentReaction.setOrientation(MOMENT_POSITIF);
momentReaction.setPointAction(position);
forceReactionIemeNoeud = [forceReactionIemeNoeud,momentReaction];
end
end
end
forceReactionIemeNoeud is the output parameter. But it is not set for
if (typeAppui == SANS_APPUI)
Force.empty(1,0);
else
and so this code could (or should?) be
if (typeAppui == SANS_APPUI)
forceReactionIemeNoeud = Force.empty(1,0);
else
This will ensure that something is returned that isn't empty.
The next piece of code to look at would be at
if(typeAppui == GOUPILLE || typeAppui == ENCASTREMENT)
% some code
elseif(typeAppui == ENCASTREMENT)
% some other code
end
Note how typeAppui == ENCASTREMENT is used for both. This would mean that if this is true, then the elseif will never be evaluated. Which of these conditions should be modified?
FInally, before we evaluate either of the above, we have already initialized
forceReactionIemeNoeud = [forceReactionIemeNoeud,forceReactionY];
so a "force" object is assigned here. But then we may do
forceReactionIemeNoeud = [forceReactionX,forceReactionIemeNoeud];
which now sets forceReactionIemeNoeud to be an array of two force objects. Is this correct? Because I suspect that this would cause a problem when this is returned and we try to call getForceX.
5 Comments
Charles-Antoine Danis
on 8 Apr 2020
Geoff Hayes
on 8 Apr 2020
Have you changed your code? Because that is a different error from before...
Charles-Antoine Danis
on 8 Apr 2020
Geoff Hayes
on 8 Apr 2020
hmmm...I can look more closely in the morning but the error message
Index exceeds the number of array elements (16084).
suggests that you are trying to use an index that is greater than 16084. What index are you using? Is this error coming from the getForcesReactionsIemeNoeud function? If so, you may need to guard against invalid indices
function [forceReactionIemeNoeud] = getForcesReactionsIemeNoeud(this,indiceNoeud)
Constantes;
forceReactionIemeNoeud = [];
if indiceNoeud <= length(this.noeuds)
typeAppui = this.noeuds(indiceNoeud).getTypeAppui();
if (typeAppui == SANS_APPUI)
forceReactionIemeNoeud = Force.empty(1,0);
else
%etc.
end
else
forceReactionIemeNoeud = Force.empty(1,0);
end
Charles-Antoine Danis
on 8 Apr 2020
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!