|
TideMan <mulgor@gmail.com> wrote in message <d853c3bb-586e-4dd6-8fb1-b6d569572246@i6g2000yqj.googlegroups.com>...
> On Jul 28, 8:54?am, "Travis " <sinuso...@hotmail.com> wrote:
> > ImageAnalyst <imageanal...@mailinator.com> wrote in message <7409b471-e14d-489f-bdff-043113213...@j21g2000yqe.googlegroups.com>...
> > > On Jul 27, 2:00?pm, "Travis " <sinuso...@hotmail.com> wrote:
> > > > I have a dataset
> > > > (depth = -[0:5 5:-1:0 0:25 25:-1:0 0:26 26:-1:0];)
> > > > time = 1:118;
> > > > that I need to separate into sections of positive and negative slopes. ?I have been able to identify the regions using...
> >
> > > > for i = 2:length(depth)-1;
> > > > if (depth(1,i-1)<=depth(1,i)) && (depth(1,i+1)>=depth(1,i))
> > > > g(i) = 1;
> > > > end
> > > > end
> >
> > > > I know it is crude, but I couldn't come up with a better way. ?I need each of these regions to be part of 3d variables (u and d) so that I can tie them into a gui using the size of the variables.
> >
> > > ------------------------------------------------------------------------
> > > Are you aware of the diff() function?
> >
> > OK, so that cleans up the for loop, but how would I then go about setting each + or - section as its own section in 3d variables?
>
> Who knows what you mean by 3d variables? I have no idea.
>
> But you can figure + and - by this:
> dy=diff(depth)
> iplus=find(dy > 0);
> iminus=find(dy <= 0);
> Now depth(iplus) are the depths where the slope is positive and depth
> (iminus) are the depths where the slope is negative or zero.
>
> Or alternatively (and preferably) by logical indexing:
> iplus=dy > 0;
> Now depth(iplus) are the depths where the slope is positive and depth
> (~iplus) are the depths where slope is negative or zero.
What I mean by 3d variable is a variable x(:,:,:) where each section of + or - has its own x and y. so that the first period of negative slope would be sldown(1,:,:), second sldown(2,:,:), etc.
|