[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
problems with if and elseif
From: |
Alabastine |
Subject: |
problems with if and elseif |
Date: |
Tue, 2 Apr 2019 05:11:44 -0500 (CDT) |
So I have the following elseif statements in a large for loop, i runs from 1
to 300 and the matrices are dynamic data of a simulation, not interesting
for now. The problem is that the uppermost elseif never gets called, while
the lowest one does (note the fprintf to show me what happens in my
confusion). So the loop finishes 'without problems' at i =300, But when I
enter in the workspace u = cnt == 4 && q(3,i) > (1/4)*pi &&
q(3,i)<(1.5/4)*pi and substitute i=104, it returns 1! How?! (I am 100% sure
cnt = 4 at i =104). Also earlier in the loop I call almost the same
statement at cnt = 2 and that works fine.
Anyone knows what's up I am very confused. I already tried using a new if
instead of elseif. didn't work.
elseif cnt == 4 && q(3,i) > (1/4)*pi && q(3,i)<(1.5/4)*pi
cnt = 5;
Q(7,i) = Q(7,i)-sign(Q(7,i-1))*cos(Fd_ang)*Fdrive;
elseif cnt == 4 && q(3,i) > pi && q(3,i) < (7/4)*pi && sign(qd(3,i)) == -1
cnt = 5;
Q(7,i) = Q(7,i)-sign(Q(7,i-1))*cos(Fd_ang)*Fdrive;
elseif cnt == 4
Q(7,i) = Q(7,i)+sign(Q(7,i-1))*cos(Fd_ang)*Fdrive;
fprintf('WTF_!_!')
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
- problems with if and elseif,
Alabastine <=