From: Nicholas Kinar on 26 May 2010 01:52 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
From: us on 26 May 2010 02:24 Nicholas Kinar <n.kinar(a)usask.ca> wrote in message <4BFCB701.1020209(a)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
From: Nicholas Kinar on 26 May 2010 10:51 > > 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
From: Alan B on 26 May 2010 12:48 Nicholas Kinar <n.kinar(a)usask.ca> wrote in message <4BFCB701.1020209(a)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".
From: Nicholas Kinar on 26 May 2010 13:15 > Nicholas Kinar <n.kinar(a)usask.ca> wrote in message > <4BFCB701.1020209(a)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
|
Pages: 1 Prev: Grouped Boxplots Next: preallocating space for a structure? |