|
"Jason " <Jay75317.remove@yahoo.com> wrote in message <ilbc6o$bcr$1@fred.mathworks.com>...
> Hello all,
>
> I am a new MATLAB user and doing a FFT and Power Spectrum Analysis on some data. I know how to find and graph the maximum point, but cannot figure out how to do the same for the 2nd. Here is the code I am using
>
> in terms of (f,Py)
> index=find(Py==max(Py));
> PrimaryPeriodStr=num2str(f(index));
> plot(f(index),Py(index),'r.','MarkerSize',25);
> text(f(index)+.01,Py(index),['Period = ',PrimaryPeriodStr]);
>
> and also
> [Pymx,loc] = max(Py)
> fmx = f(loc)
Hi Jason
You may do it in 3 lines:
[P1,i1] = max(Py);
[P2,i2] = max(Py(Py~=P1));
plot(f(i1),P1,'.r', f(i2),P2,'.m');
|