Conditional statement of matrix

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

답변 (1개)

madhan ravi
madhan ravi 2019년 5월 16일

0 개 추천

n=find(A==k) % no loop is needed if you want to know the instances of the satisfied condition

댓글 수: 2

Tino
Tino 2019년 5월 16일
편집: Tino 2019년 5월 16일
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 2019년 5월 16일
편집: madhan ravi 2019년 5월 16일
assert(~any((X > K)|(X < K)),'Uhoo found the guy')

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

태그

질문:

2019년 5월 16일

편집:

2019년 5월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by