|
"atul mahajan" <atul_techno@yahoo.com> wrote in message <hdf3dn$2mv$1@fred.mathworks.com>...
> Hi
>
> I have a matrix of size about 1X400000. It stores a sinusoidal signal with increasing amplitude.
>
> For example, 1st peak is at 2V, 2nd peak at 2.5V, 3rd peak at 3V and so on until it saturates at some particular level. i want to calculate the time at which each peak occurs. can some one please suggest me the way to do it in matlab.
>
> thanks in advance
>
> atul
Looks like there are some functions in the signal processing toolbox that will do this, e.g. findpeaks. Or, if you need to write your own simple function (and the data is not noisy) you could try something like this:
a = 0:.01:100;
b = sin(a).*a;
d = b(2:end)-b(1:(end-1));
s = sign(d);
t = s(2:end)-s(1:(end-1));
f = find(t);
plot(a,b,'-',a(f),b(f),'o')
The f variable contains the indexes for the location of the peaks. If the data is noisy then you have more work to do (smooth the data first, etc.).
James Tursa
|