I have two matrices: X is 100 by 1e5, complex double and Y is 1 by 1e5. For each row, X matrix contains either one peak value or two peak values.
Based on the index(indices) of the (these) peak value(s), I have to know the corresponding value of Y matrix. But it is all random i.e. the peak values are different from each other. Also the X matrix contains complex values.
Please help.
Faisal

3 commentaires

Azzi Abdelmalek
Azzi Abdelmalek le 29 Déc 2014
Can you explain with a short example?
Faisal Memon
Faisal Memon le 29 Déc 2014
Kindly see the figure. It is zoom in. The graph has 2 peaks, one is centered around zero, the other is at some value of X-axis. I need that value of x-axis where the second peak is located. Please help
Faisal Memon
Faisal Memon le 29 Déc 2014
the fig 2 is same as fig 1 but with less zoom.

Connectez-vous pour commenter.

 Réponse acceptée

Image Analyst
Image Analyst le 29 Déc 2014
if you "need that value of x-axis where the second peak is located." then try this, where you start looking for the max starting from the half way point (just the right half of the signal).
middleElement = floor(length(X)/2);
[maxValue, index] = max(X(middleElement:end));
yIndexOfMax = index + middleElement;
yAtMax = Y(yIndexOfMax);
Note that X is your signal (normally what people call Y), and your Y is what people normally call x - not sure why you did it that way, but I followed your unconvential notation.
You might need to look at the magnitude, real part, or imaginary part of X instead of complex values because the max is not defined for a fully complex number.

9 commentaires

Faisal Memon
Faisal Memon le 29 Déc 2014
Thank you friend for the nice explanation. Yes, you are right that i called X as Y and Y as X, ;). May be I was fed up finding the ways to dig out that value accurately. Well i give a try to your proposed method and lets see whether it works for me.
Thanks once again
Faisal
Faisal Memon
Faisal Memon le 29 Déc 2014
Modifié(e) : Faisal Memon le 29 Déc 2014
Dear @Image Analyst
The max command finds just one maximum value, however the second peak in the graph is not always highest peak. So the method does not give me desired results. Moreover, the two peaks shown in graph are for X(1,:) only, so when X is 100 by 1e5, each row will have one or two peaks.
Image Analyst
Image Analyst le 29 Déc 2014
It does not matter if the second peak is not the highest. When you examine just the right half of the data, the first peak is excluded and so then the right peak IS the highest peak and will be found. Isn't that right? Like in your Fig2, if you take data only to the right of -5, then it won't see the peak at -2 and will detect only the peak at 0. And for fig1, it will not consider data to the left of -4 and so will find only the peak at 0. I really fail to see how this does not work. Please attach your data and code so I can see what's going wrong.
Faisal Memon
Faisal Memon le 30 Déc 2014
Modifié(e) : Faisal Memon le 30 Déc 2014
Dear @Image Analyst
Yes your logic is right, but the case is not so simple. I am not interested in the peak centered at zero always but the peak that is at some non-zero number. Kindly see the figure 3, attached with thiis comment. The peaks shown in this figure correspond to each row of the Matrix X, that is 100 by 1e, I mean for each row of X, one or two peaks are generated.
My intention is to find the dimension of the peak that is centered at non-zero number. But for any row of the X Matrix , there may be only one peak centered around zero, then that peak dimension will be required, in other words that would be the solution. I respect your experience but if I add the code, then again I have to explain you the details of each line b/c the code is complicated.
Please help
Image Analyst
Image Analyst le 30 Déc 2014
Yes, that does look substantially different that the original figures that I was replying about. If you have the Signal Processing Toolbox you can try findpeaks(). It will find the peak locations and then you can examine each peak for things like FWHM or whatever you want to know about them.
Faisal Memon
Faisal Memon le 31 Déc 2014
Modifié(e) : Faisal Memon le 31 Déc 2014
Dear @Image Analyst
Yes yes the command findpeaks() works, thank you.
Image Analyst
Image Analyst le 31 Déc 2014
OK, you're welcome. If that works, then can you mark the answer as "Accepted". Otherwise ask a followup question.
Faisal Memon
Faisal Memon le 15 Jan 2015
Dear @Image Analyst
I need your help in ifft problem. I have sent you an email too.
Faisal
Image Analyst
Image Analyst le 15 Jan 2015
I don't read the email associated with this account. Post a new question and someone will answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by