I have a data set that cotnains FWHM. I want to identify the 2 highest values and highlight on a graph. I have used sort rows and picked out the 2 highest values given by Cam2G:
Cam2G =
2.6200
2.5800
If my unsorted data is dataR, how do I get the index in this where the values Cam2G occur?

 채택된 답변

Guillaume
Guillaume 2015년 1월 19일

1 개 추천

When you did your sorting, you should have captured the second return value, which is the indices of the sorted values.
dataR = [2.4 2.62 .3 2.5 2.58];
[cam2G, indices] = sort(dataR);
cam2G = cam2G([1 2]);
indices = indices([1 2]);
If somehow, it's too late:
indices = arrayfun(@(v) find(dataR == v, 1), cam2G);

댓글 수: 3

Thats great, thankyou. If now i have set of the two max values for Cam2G and do the same for another data set Cam2Gb, so now there are 4 max values. How do I find the overall max, I tried:
max(max(Cam2G, Cam2Gb))
i get
Error using max
Too many input arguments.
max([Cam2G(:); Cam2Gb(:)])
NB: used (:) to ensure both are column vectors; use concatenation as appropriate to the storage direction.
Jason
Jason 2015년 1월 19일
thankyou

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

추가 답변 (2개)

dpb
dpb 2015년 1월 19일

1 개 추천

Use the optional second index return value from sortrows
[mx,imx]=sortrows(FWHM);
Keep the first N of each...
Jason
Jason 2015년 1월 19일

1 개 추천

But I need to find the index in the unsorted data, not the sorted?

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

질문:

2015년 1월 19일

댓글:

2015년 1월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by