loop that checks conditions and counts the results
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Adam Danz
il 30 Mar 2021
Modificato: Adam Danz
il 31 Mar 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 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!