필터 지우기
필터 지우기

Extract one element from row vectors?

조회 수: 1 (최근 30일)
Mary Jon
Mary Jon 2013년 11월 27일
댓글: Azzi Abdelmalek 2013년 11월 27일
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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 27일
A(A==max(A))=[]
  댓글 수: 5
Mary Jon
Mary Jon 2013년 11월 27일
if I have complex number how can finding its magnitude
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 27일
abs(a)
see also
angle(a)
imag(a)
real(a)

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

추가 답변 (1개)

Wayne King
Wayne King 2013년 11월 27일
편집: Wayne King 2013년 11월 27일
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'))= [];

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by