what is causing this error?

1 Ansicht (letzte 30 Tage)
Ariana Garcia
Ariana Garcia am 18 Mär. 2019
Beantwortet: KSSV am 18 Mär. 2019
PosVecP = zeros(nMembersP, 3); %Initialize memory storage
UnitVecP = zeros(nMembersP, 3);
OppPosVecP = zeros(nMembersP, 3);
for (j = 1 : nMembersP)
SN = MemberP(j,1); %SN = start node
EN = MemberP(j,2); %EN = end node
PosVecP(j,:)= NodeP(EN,:)-NodeP(SN,:);
UnitVecP(j,:)=PosVecP(j,:)./norm(PosVecP(j,:));
OppUnitVecP(j,:)= -PosVecP(j,:)./norm(PosVecP(j,:));
%Finish this section to compute the position vector, length, unit vector,
%and negative unit vector for each member in the truss.
end % for j (members)
WHY DOES THIS ERROR MESSAGE KEEP POPPING UP WHEN I RUN SECTION
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in testruncp3 (line 92)
PosVecP(j,:)= NodeP(EN,:)-NodeP(SN,:);

Antworten (1)

KSSV
KSSV am 18 Mär. 2019
Note that in matlab the indexing shoul dbe always a posittive integer or a logical. You are suing negative number, so error.
A = rand(10,1) ;
A(1) % no error
A(10) % no error
A(A>0.5) % logical allowed
A(0) % error, 0 double not allowed
A(-1) % error , negative not allowed
Put your code in debug mode and check the indices.

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by