Extract one element from row vectors?

I have row vectors how can I extract one element from this vector;
A=[1 2 3 4 5]; how extract max value (5)from A MATRIX
to be A=[1 2 3 4]; only

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 27 de Nov. de 2013
A(A==max(A))=[]

5 comentarios

Mary Jon
Mary Jon el 27 de Nov. de 2013
thank you Abdelmalek .
Mary Jon
Mary Jon el 27 de Nov. de 2013
Editada: Mary Jon el 27 de Nov. de 2013
how can sum the square of the remaining elements of A
sum(A.^2)
Mary Jon
Mary Jon el 27 de Nov. de 2013
if I have complex number how can finding its magnitude
abs(a)
see also
angle(a)
imag(a)
real(a)

Iniciar sesión para comentar.

Más respuestas (1)

Wayne King
Wayne King el 27 de Nov. de 2013
Editada: Wayne King el 27 de Nov. de 2013
In addition to Azzi's suggestion you can use
A(A~=max(A))
but keep in mind that both will remove multiple values if the max() occurs more than once.
For example:
A = [1 2 3 4 5 5];
If the max occurs more than once, you have to use a different technique to remove which entry you want. For example, say you want to just remove the first time the max occurs
maxval = max(A);
A(find(A==max(A),1,'first'))= [];

Categorías

Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 27 de Nov. de 2013

Comentada:

el 27 de Nov. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by