finding the values

1 visualización (últimos 30 días)
FIR el 3 de Mzo. de 2012
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

Respuesta aceptada

Image Analyst
Image Analyst el 3 de Mzo. de 2012
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 ];
if any(A==B)
message = sprintf('The B value of %d is in A.', B);
Needless to say, you can use the B1 variable instead of B.

Más respuestas (1)

the cyclist
the cyclist el 3 de Mzo. de 2012
You need the ismember() command.


Más información sobre Creating and Concatenating Matrices 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!

Translated by