From: RailGun09 hui on
Hi people. I'm currently doing a project of getting the timing between 2 peaks. Hence i plan to go about it by getting the coordinates of each peak and i can then minus the corresponding X coordinates for the timing.

I have tried using functions like 'findpeaks', 'max' and also 'peaks' but to no avail. I could only get the Y value from 'findpeaks' but not the X value.

Hope that you people out there can help me. Thanks very much.
From: us on
"RailGun09 hui" <zhizhehui(a)hotmail.com> wrote in message <hqugq9$aka$1(a)fred.mathworks.com>...
> Hi people. I'm currently doing a project of getting the timing between 2 peaks. Hence i plan to go about it by getting the coordinates of each peak and i can then minus the corresponding X coordinates for the timing.
>
> I have tried using functions like 'findpeaks', 'max' and also 'peaks' but to no avail. I could only get the Y value from 'findpeaks' but not the X value.
>
> Hope that you people out there can help me. Thanks very much.

one of the many solutions

x=0:30:360;
y=sind(x)+rand(size(x));
line(x,y,'marker','s');
[ym,ix]=find(sign(diff(y))==-1,1,'first'); % <- a very simple peak finder...
line(x(ix),y(ix),'marker','s','markerfacecolor',[1,0,0]);

us
From: RailGun09 on
"us " <us(a)neurol.unizh.ch> wrote in message <hqupst$jo7$1(a)fred.mathworks.com>...
> "RailGun09 hui" <zhizhehui(a)hotmail.com> wrote in message <hqugq9$aka$1(a)fred.mathworks.com>...
> > Hi people. I'm currently doing a project of getting the timing between 2 peaks. Hence i plan to go about it by getting the coordinates of each peak and i can then minus the corresponding X coordinates for the timing.
> >
> > I have tried using functions like 'findpeaks', 'max' and also 'peaks' but to no avail. I could only get the Y value from 'findpeaks' but not the X value.
> >
> > Hope that you people out there can help me. Thanks very much.
>
> one of the many solutions
>
> x=0:30:360;
> y=sind(x)+rand(size(x));
> line(x,y,'marker','s');
> [ym,ix]=find(sign(diff(y))==-1,1,'first'); % <- a very simple peak finder...
> line(x(ix),y(ix),'marker','s','markerfacecolor',[1,0,0]);
>
> us

Thanks for your help but I am not very sure how to implement your solution in my project. As what i would want would be to locate each peak's x and y coordinate. It would be better to explain clearer your solution as I'm still new to matlab so maybe i might have missed out something important here. And also for my project i'm using the plot function and you're using the line function. So will it affect what i want? Thanks.
From: us on
"RailGun09 " <zhizhehui(a)hotmail.com> wrote in message <hqv21h$rpo$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <hqupst$jo7$1(a)fred.mathworks.com>...
> > "RailGun09 hui" <zhizhehui(a)hotmail.com> wrote in message <hqugq9$aka$1(a)fred.mathworks.com>...
> > > Hi people. I'm currently doing a project of getting the timing between 2 peaks. Hence i plan to go about it by getting the coordinates of each peak and i can then minus the corresponding X coordinates for the timing.
> > >
> > > I have tried using functions like 'findpeaks', 'max' and also 'peaks' but to no avail. I could only get the Y value from 'findpeaks' but not the X value.
> > >
> > > Hope that you people out there can help me. Thanks very much.
> >
> > one of the many solutions
> >
> > x=0:30:360;
> > y=sind(x)+rand(size(x));
> > line(x,y,'marker','s');
> > [ym,ix]=find(sign(diff(y))==-1,1,'first'); % <- a very simple peak finder...
> > line(x(ix),y(ix),'marker','s','markerfacecolor',[1,0,0]);
> >
> > us
>
> Thanks for your help but I am not very sure how to implement your solution in my project. As what i would want would be to locate each peak's x and y coordinate. It would be better to explain clearer your solution as I'm still new to matlab so maybe i might have missed out something important here. And also for my project i'm using the plot function and you're using the line function. So will it affect what i want? Thanks.

well...

firstly, see

help find;

% to find out that the second output arg IX returns the position
% where FIND found the condition - in this case: the YM, the value of the peak

[ym,ix]=find(...condition=true...);

% now, we use this linear index IX to retrieve the respective value in the array X

line(x(ix),y(ix),...)

% note: y(ix) <==> ym, but we use y(ix) for educational purposes...

us
From: RailGun09 on
"us " <us(a)neurol.unizh.ch> wrote in message <hqv374$cht$1(a)fred.mathworks.com>...
> "RailGun09 " <zhizhehui(a)hotmail.com> wrote in message <hqv21h$rpo$1(a)fred.mathworks.com>...
> > "us " <us(a)neurol.unizh.ch> wrote in message <hqupst$jo7$1(a)fred.mathworks.com>...
> > > "RailGun09 hui" <zhizhehui(a)hotmail.com> wrote in message <hqugq9$aka$1(a)fred.mathworks.com>...
> > > > Hi people. I'm currently doing a project of getting the timing between 2 peaks. Hence i plan to go about it by getting the coordinates of each peak and i can then minus the corresponding X coordinates for the timing.
> > > >
> > > > I have tried using functions like 'findpeaks', 'max' and also 'peaks' but to no avail. I could only get the Y value from 'findpeaks' but not the X value.
> > > >
> > > > Hope that you people out there can help me. Thanks very much.
> > >
> > > one of the many solutions
> > >
> > > x=0:30:360;
> > > y=sind(x)+rand(size(x));
> > > line(x,y,'marker','s');
> > > [ym,ix]=find(sign(diff(y))==-1,1,'first'); % <- a very simple peak finder...
> > > line(x(ix),y(ix),'marker','s','markerfacecolor',[1,0,0]);
> > >
> > > us
> >
> > Thanks for your help but I am not very sure how to implement your solution in my project. As what i would want would be to locate each peak's x and y coordinate. It would be better to explain clearer your solution as I'm still new to matlab so maybe i might have missed out something important here. And also for my project i'm using the plot function and you're using the line function. So will it affect what i want? Thanks.
>
> well...
>
> firstly, see
>
> help find;
>
> % to find out that the second output arg IX returns the position
> % where FIND found the condition - in this case: the YM, the value of the peak
>
> [ym,ix]=find(...condition=true...);
>
> % now, we use this linear index IX to retrieve the respective value in the array X
>
> line(x(ix),y(ix),...)
>
> % note: y(ix) <==> ym, but we use y(ix) for educational purposes...
>
> us

Hi, i understand that values that ym and ix give me is from the matrix itself. But what i would want are values from the respective axes itself. For example like for y axis would be a value of 356.456 and x would be a value of 0.567. Is it possible?