Identifying horizontal sections of a curve

  • Follow


Hello---

I have a vector 'v' which contains values sampled at discrete times 
given in another vector 't'.  After using the command 'plot(v,t)' in 
Matlab, I would like to identify sections of the curve which appear to 
be "nearly" horizontal on the plot.

Is there a robust way of doing this numerically using Matlab?

Nicholas

0
Reply n.kinar (156) 5/26/2010 5:52:01 AM

Nicholas Kinar <n.kinar@usask.ca> wrote in message <4BFCB701.1020209@usask.ca>...
> Hello---
> 
> I have a vector 'v' which contains values sampled at discrete times 
> given in another vector 't'.  After using the command 'plot(v,t)' in 
> Matlab, I would like to identify sections of the curve which appear to 
> be "nearly" horizontal on the plot.
> 
> Is there a robust way of doing this numerically using Matlab?
> 
> Nicholas

a hint:

     help sin;     % <- and other siblings of this series of functions...

us
0
Reply us 5/26/2010 6:24:35 AM


>
> a hint:
>
> help sin; % <- and other siblings of this series of functions...
>
> us

Hello us---

Thank you very much for your response!  I've looked at the help file for 
the sin() function.  Do you mean that I need to apply sin() to my data 
and then perhaps look for turning points in the curve?

Nicholas
0
Reply Nicholas 5/26/2010 2:51:42 PM

Nicholas Kinar <n.kinar@usask.ca> wrote in message <4BFCB701.1020209@usask.ca>...
> Hello---
> 
> I have a vector 'v' which contains values sampled at discrete times 
> given in another vector 't'.  After using the command 'plot(v,t)' in 
> Matlab, I would like to identify sections of the curve which appear to 
> be "nearly" horizontal on the plot.
> 
> Is there a robust way of doing this numerically using Matlab?
> 
> Nicholas

Try this:

% sample data
% t = 0:255;
% v = cumsum(randn(size(t)));

thresh=1;
n=find(abs(diff(v)./diff(t)) > thresh); % find points with high slope dv/dt
tt = reshape([t(n); t(n+1); nan(size(n))],[],1);
vv = reshape([v(n); v(n+1); nan(size(n))],[],1);

plot(v,t,'b-',vv,tt,'r')

The robustness of this will depend on exactly what "horizontal" means to you, and exactly what constitutes a "section of the curve". 
0
Reply Alan 5/26/2010 4:48:05 PM

> Nicholas Kinar <n.kinar@usask.ca> wrote in message
> <4BFCB701.1020209@usask.ca>...
>> Hello---
>>
>> I have a vector 'v' which contains values sampled at discrete times
>> given in another vector 't'. After using the command 'plot(v,t)' in
>> Matlab, I would like to identify sections of the curve which appear to
>> be "nearly" horizontal on the plot.
>>
>> Is there a robust way of doing this numerically using Matlab?
>>
>> Nicholas
>
> Try this:
>
> % sample data
> % t = 0:255;
> % v = cumsum(randn(size(t)));
>
> thresh=1;
> n=find(abs(diff(v)./diff(t)) > thresh); % find points with high slope dv/dt
> tt = reshape([t(n); t(n+1); nan(size(n))],[],1);
> vv = reshape([v(n); v(n+1); nan(size(n))],[],1);
>
> plot(v,t,'b-',vv,tt,'r')
>
> The robustness of this will depend on exactly what "horizontal" means to
> you, and exactly what constitutes a "section of the curve".

Agreed; thank you very much, Allen.

Nicholas
0
Reply Nicholas 5/26/2010 5:15:59 PM

4 Replies
216 Views

(page loaded in 0.084 seconds)

Similiar Articles:













7/24/2012 1:46:21 AM


Reply: