Thread Subject: separating data

Subject: separating data

From: Travis

Date: 27 Jul, 2009 18:00:20

Message: 1 of 5

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.

Subject: separating data

From: ImageAnalyst

Date: 27 Jul, 2009 19:10:41

Message: 2 of 5

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?

Subject: separating data

From: Travis

Date: 27 Jul, 2009 20:54:01

Message: 3 of 5

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7409b471-e14d-489f-bdff-0431132134d5@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?

Subject: separating data

From: TideMan

Date: 27 Jul, 2009 23:29:50

Message: 4 of 5

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.

Subject: separating data

From: Travis

Date: 28 Jul, 2009 13:47:01

Message: 5 of 5

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.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
datasets Sprinceana 27 Jul, 2009 17:09:42
rssFeed for this Thread

Contact us at files@mathworks.com