Find the maxima in a graph

I know that this question has been answered a lot of times in this forum but I am a beginner in MATLAB and I was not able to find a suitable solution for myself.
[IMG]http://i40.tinypic.com/nx4cih.jpg[/IMG]. or http://tinypic.com/r/nx4cih/5
here is the link for uploaded graph. The variable which I am plotting has dimensions of 2705*196. How can i find the maximum peak of the graph.

댓글 수: 1

Ricky
Ricky 2013년 5월 23일
Hello find the link for uploaded file
simply use plot command. I want to find maxima of this data. The graph I uploaded in tinypic.

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

답변 (3개)

Image Analyst
Image Analyst 2013년 5월 22일

0 개 추천

Try this:
[maxDataValue, indexAtMax] = max(yourData);

댓글 수: 3

Image Analyst
Image Analyst 2013년 5월 22일
The index value will be correct. If you say it's not, it is probably because your x axis is not in elements but in some kind of real world units. In that case you'll need a calibration factor that converts the element into real world units. You can upload your data here: http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Ricky
Ricky 2013년 5월 22일
Hello Image Analyst, I am sorry I am not able to upload the data as these websites are blocked in my office
Ricky
Ricky 2013년 5월 22일
편집: Ricky 2013년 5월 22일
Hello Image analyst find the link for uploaded file
simply use plot command. I want to find maxima of this data. The graph I uploaded in tinypic.

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

Iain
Iain 2013년 5월 22일

0 개 추천

[m K] = max(Variable(:)) tells you the maximum value anywhere in Variable (m), and it's index (K).

댓글 수: 4

Ricky
Ricky 2013년 5월 22일
your solution gives me the correct value of m but the index value is not correct.
Iain
Iain 2013년 5월 22일
The index value is correct when used as: Variable(K)
Image Analyst's approach is also correct, but assumes you want the max of each column, and his indexAtMax is also correct, when used as Variable(indexAtMax(column_number),column_number)
Image Analyst
Image Analyst 2013년 5월 22일
편집: Image Analyst 2013년 5월 23일
He showed one dimensional data in his screenshot, not 2D data. That's why I didn't use (:). Plus the values will be the same no matter if the 1D data is a row vector or a column vector. A row vector will not give you the value of each column back - it will give you the max like you expect. If someone has a 2D matrix and want the overall matrix then (:) is correct. Of course it will also work with 1D arrays as well though it's not necessary.
Iain
Iain 2013년 5월 23일
Ah - Due to the firewall I'm stuck with here, I can't see the screenshot.

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

José-Luis
José-Luis 2013년 5월 22일

0 개 추천

Sounds like you want the sub indexes (row, column) not the linear indexes.
your_data = rand(10,20);
[row col] = ind2sub(size(your_data),find(your_data == max(your_data(:))))

댓글 수: 8

Image Analyst
Image Analyst 2013년 5월 22일
Ricky's data looks to me like 1D data. What does it look like to you?
José-Luis
José-Luis 2013년 5월 22일
Sure does. But he provides some conflicting information. Rick says the variable has size (2075,196). My guess was the plot is not very informative, and that he meant to use surf() or the likes.
Oh well, if all questions were cristal clear, I guess it would take away some of the fun. It would make answering questions more efficient though, removing the guessing part.
Image Analyst
Image Analyst 2013년 5월 23일
You're right. I didn't notice that. That certainly does contradict what his plot shows.
Ricky
Ricky 2013년 5월 23일
I have uploaded the data also which I am plotting. After i plot this I get the above graph.
José-Luis
José-Luis 2013년 5월 23일
편집: José-Luis 2013년 5월 23일
Could you explain why the alternatives proposed here do not fit the bill? The data and the plot don't explain things, at least no to me. What do you mean by maxima? Image Analyst answer gives you the maximum for every column of data. Iain and me give you the maximum for the entire matrix. I cannot think of another maximum.
Image Analyst
Image Analyst 2013년 5월 23일
I haven't downloaded the data yet, but if it is a 2D array, then what are you plotting? Just one of the columns or one of the rows? Or you just plotted the whole thing and were unaware of what it would plot? What do you want to plot? A row or a column, or both, perhaps with surf() or waterfall()?
Ricky
Ricky 2013년 5월 23일
Hi
First of all I would like to apologise for my mistake. The data is indeed a two dimensional data with 2705 rows and 196 column. The graph that I am plotting is like a maxima of each column. So there are some columns where all the values are zero and some columns where I get some values which are plotted.
I still do not understand I am plotting 2d data with simple plot command. I am using MATLAB version R 2013a.
José-Luis
José-Luis 2013년 5월 23일
Then you get the maximums with what Image Analyst suggested. Please look at the documentation for max().
If you want the row, columns of each column maximum, then you need to transform the linear indexes to subindexes. Please look at ind2sub().
If you want to plot a surface (2d data) then you can't use plot(). Please look at the documentation for surf(). There you will find links to similar plotting tools, that could also work.

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2013년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by