Vector problem

I have a (3,51)-sized vector, I would like to remove all data (set to zero) that does not belong to a certain interval,
x1 < x < x2
How can I do this efficiently?
Many thanks!

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 22 de Jul. de 2011

0 votos

A=rand(3,51);
Index=and(A<0.8,A>0.5);
A(Index)=0;

4 comentarios

Lizan
Lizan el 22 de Jul. de 2011
Thanks you, it worked!
Just one question, what does command 'and()' specifically do?
Fangjun Jiang
Fangjun Jiang el 22 de Jul. de 2011
It is the function format of doing logical and operation, such as x & y, you can do and(x,y)
Sean de Wolski
Sean de Wolski el 22 de Jul. de 2011
elements of A that are less than 0.8 AND those same elements of A greater than 0.5.
Jan
Jan el 22 de Jul. de 2011
@Susan: You could read the documentation "doc and" also. Do we assist to solve your homework?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 22 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by