Conditional statement of matrix

4 vues (au cours des 30 derniers jours)
Tino
Tino le 16 Mai 2019
Modifié(e) : madhan ravi le 16 Mai 2019
hello
I have the following dataset
A
1
2
2
3
4
5
6
7
5
.
.
.
n
I want to write a conditional statement that will go through the rows and if it identify a given number ( for instance K = 7 ) it stops
and continues until the 7 is identified.
my code is not working as I
for n = (1:2)
if find(x > K,1,'first')
disp([' WARNING' num2str(n)])
else
disp(' No warning signs ')
continue
end
end
Help please
Tino

Réponses (1)

madhan ravi
madhan ravi le 16 Mai 2019
n=find(A==k) % no loop is needed if you want to know the instances of the satisfied condition
  2 commentaires
Tino
Tino le 16 Mai 2019
Modifié(e) : Tino le 16 Mai 2019
Hi Madhan thanks a lot
But if I want to write a statement that
X > K or X < K
and a statement
yes 'found number'. How do I do it
Regards
madhan ravi
madhan ravi le 16 Mai 2019
Modifié(e) : madhan ravi le 16 Mai 2019
assert(~any((X > K)|(X < K)),'Uhoo found the guy')

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by