|
Hi Somnath,
Perhaps findpeaks() will work for you? You can use find(). Both will return the locations (x-indices) where the peaks (as you define them) occur.
hope that helps,
wayne
To find the maxima of sin(x) (where you also want the -1 value to be interpreted as a peak)
x = 0:.01:(2*pi);
y = sin(x);
[pks,loc] = findpeaks(abs(y),'minpeakheight',0.9);
loc =
158 472
% y(158) is equal to 1
x(158) % the x-location is pi/2
ans =
1.5700
hope that helps,
wayne
"Somnath Karmakar" <somnath1402@rediffmail.com> wrote in message <h00b7t$7jp$1@fred.mathworks.com>...
> Hello,
> I am very new to Matlab. I have a function F (x) which has (+) and (-) peaks on both sides of x axis i.e the horizontal axis. I would like to array all values of F (x) for both peaks and corresponding x values.
> Simply if we consider, F(x) = sin(x), (+) peak value is 1and corresponding x= (pi/2),
> and (-) peak value is -1, corresponds to x= (3*pi/2) and so on. Now wish to array of these
> for a given range.
> Hope to get proper direction how to proceed.
>
> Thanks
|