If statement multiple condition overposing

2 visualizaciones (últimos 30 días)
Alexandra Silva
Alexandra Silva el 4 de Nov. de 2019
Comentada: Alexandra Silva el 4 de Nov. de 2019
Does anybody know why this is not working?
It gives me the events that are < and = to zero for the left leg but for the right leg only gives me the events that are > than 0
NoncomplianceIndex = 0;
for i = 1:length(time)
if LeftFrontLegX(i) <= 0 && RightFrontLegX(i) >= 0,NoncomplianceIndex = NoncomplianceIndex + 1; end;
end;
How do the conditions work in matlab? they cannot overlap? if one is <=0 the other one cannot be >=0
Thank you so much

Respuestas (2)

KALYAN ACHARJYA
KALYAN ACHARJYA el 4 de Nov. de 2019
Editada: KALYAN ACHARJYA el 4 de Nov. de 2019
Does anybody know why this is not working?
NoncomplianceIndex=??? % Define may be as zero
for i=1:length(time)
if LeftFrontLegX(i)<=0 && RightFrontLegX(i)>=0
NoncomplianceIndex=NoncomplianceIndex + 1;
end
end
Same can be done without loop
  1 comentario
Alexandra Silva
Alexandra Silva el 4 de Nov. de 2019
Sorry I din't show the whole code in order to simplify

Iniciar sesión para comentar.


David Hill
David Hill el 4 de Nov. de 2019
No need for a loop.
Noncompliance=sum(LeftFrontLegX<=0 & RightFrontLegX>=0);

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by