フィルターのクリア

how to find maximum value of a column,which satisfies a condition.

8 ビュー (過去 30 日間)
Chandradhar Savanth
Chandradhar Savanth 2013 年 10 月 27 日
コメント済み: Chandradhar Savanth 2013 年 10 月 27 日
hi.. suppose i have a matrix as given below
x f1 f2 rank
0.0002 0.0000 3.9991 1.0000
0.7672 0.5886 1.5198 1.0000
1.0987 1.2071 0.8124 1.0000
1.1767 1.3845 0.6779 1.0000
2.4407 5.9572 0.1943 1.0000
-0.2008 0.0403 4.8434 2.0000
3.0549 9.3324 1.1128 2.0000
3.5944 12.9199 2.5422 3.0000
4.0472 16.3800 4.1911 4.0000
-4.6946 22.0392 44.8175 5.0000
here x,f1,f2,rank represents 1st,2nd,3rd,4th columns respectively of the above matrix.
i want to find maximum value and minimum value of 'f1' column whose 'rank'=1 i.e, my answer should be max.value=5.9572,min.value = 0.0000
similarly max.value and min.value of 'f2' column whose 'rank'=1;i.e, my answer should be
max.value = 3.9991;min.value= 0.1943
is there a method to find out without using loops .
Thank you
with regards,
Chandradhar Savanth.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 27 日
編集済み: Azzi Abdelmalek 2013 年 10 月 27 日
You can use max and min function. If M is your matrix
f1=M(:,2);
max_f1=max(f1)
min_f1=min(f1)
% you can do the same for f2
f2=M(:,3);
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 27 日
idx=M(:,4)==1;
f1=M(:,2);
max_f1=max(f1(idx))
min_f1=min(f1(idx))
Chandradhar Savanth
Chandradhar Savanth 2013 年 10 月 27 日
It's working..
Thank you
Azzi Abdelmalek

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by