loop that checks conditions and counts the results
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a question about a loop and how i can write it. I have created a random generator that gives numbers for four variables: x, y, z, s.
x is the floor number
y is the no of floor that is on fire
z is the detection of fire (either detect or not)
s is the extinguishing of fire ( either extinguish or not) it is also associated with each floor
now i want to create a loop that checks for the following 4 states and counts how many times they were satisfied.
1st state, x<y and count it
2nd state, for x>y check if z=0 (not detected) and count it else go to 3rdstate
3rd state, for x>y check if z=1 and s=0(not extinguished) and count it else go to 4th state
4th state, for x>y check if z=1 and s=1(detected) and count it
0 comentarios
Respuestas (1)
Adam Danz
el 30 de Mzo. de 2021
Editada: Adam Danz
el 31 de Mzo. de 2021
I get the gist of the question but don't understand the details listed at the end of the question. Here's how to count conditions. You can adapt it to your needs. If you have any follow-up questions or want to add some details, let us know.
n = sum(x>y & z==1)
This requires the x,y,z vectors to all have the same number of elements.
0 comentarios
Ver también
Categorías
Más información sobre Logical 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!