finding the values

i have in A=[2 5 6 3 ] B=[3],B1=[4]
i want to compare A,B and A,B if value of B is found in A, i want to display value is found
please help

 채택된 답변

Image Analyst
Image Analyst 2012년 3월 3일

0 개 추천

As long as you're simply doing what you asked (to find a single scalar value in a vector), you can use any(A==B) like this:
A=[2 5 6 3 ];
B=3;
if any(A==B)
message = sprintf('The B value of %d is in A.', B);
uiwait(msgbox(message));
end
Needless to say, you can use the B1 variable instead of B.

추가 답변 (1개)

the cyclist
the cyclist 2012년 3월 3일

0 개 추천

You need the ismember() command.

카테고리

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

태그

질문:

FIR
2012년 3월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by