フィルターのクリア

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'))= [];
  1 件のコメント
Mary Jon
Mary Jon 2013 年 11 月 27 日
Thank you King,

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by