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

20 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Robust Control Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by