From: Kenneth Galea on
Hi everyone.

I have a 2dimensional array having certain important data (x-y coordinates of an image).
This data is seperated by non important data let it be 'x'. E.g.
x x x 2 4 6 8 x x x x 5 4 3 2 1 x x x x 6 5 4 3 7 6 8
I need to select (2 & 8), (5 & 1) , (6 and 8) i.e. the first and last element of each set and store them seperately. Is there a way to do this using a Matlab function???
Please these numbers are given as an example (each represents x,y coordinates)

Regards
Kenneth
From: us on
"Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hp6lss$jm3$1(a)fred.mathworks.com>...
> Hi everyone.
>
> I have a 2dimensional array having certain important data (x-y coordinates of an image).
> This data is seperated by non important data let it be 'x'. E.g.
> x x x 2 4 6 8 x x x x 5 4 3 2 1 x x x x 6 5 4 3 7 6 8
> I need to select (2 & 8), (5 & 1) , (6 and 8) i.e. the first and last element of each set and store them seperately. Is there a way to do this using a Matlab function???
> Please these numbers are given as an example (each represents x,y coordinates)
>
> Regards
> Kenneth

CSSM needs a working input/output example, not a verbose description...

us
From: Kenneth Galea on
"us " <us(a)neurol.unizh.ch> wrote in message <hp6mis$sgh$1(a)fred.mathworks.com>...
> "Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hp6lss$jm3$1(a)fred.mathworks.com>...
> > Hi everyone.
> >
> > I have a 2dimensional array having certain important data (x-y coordinates of an image).
> > This data is seperated by non important data let it be 'x'. E.g.
> > x x x 2 4 6 8 x x x x 5 4 3 2 1 x x x x 6 5 4 3 7 6 8
> > I need to select (2 & 8), (5 & 1) , (6 and 8) i.e. the first and last element of each set and store them seperately. Is there a way to do this using a Matlab function???
> > Please these numbers are given as an example (each represents x,y coordinates)
> >
> > Regards
> > Kenneth
>
> CSSM needs a working input/output example, not a verbose description...
>
> us

Sorry if I'm not clear.

What I have exactly is best grasping regions/coordinates of a polygon (i.e. linear sides) which can be of unequal lengths. These are being saved in an array and they are seperated by 'non important values e.g. 1000', which represent the corners.
this is a woking example:
group_threshold = 32
selection = bwareaopen(grasping_regions~=-1000, group_threshold)
selected_grasping_regions = grasping_regions .* selection
selected_grasping_regions(selection == 0) = -1000

Now I need to select these linear regions individually by taking their first and last element of each set in order to draw its line and then take a normal vector to it to analyse further.

Regards
Kenneth
From: us on
"Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hp6nod$f3n$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <hp6mis$sgh$1(a)fred.mathworks.com>...
> > "Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hp6lss$jm3$1(a)fred.mathworks.com>...
> > > Hi everyone.
> > >
> > > I have a 2dimensional array having certain important data (x-y coordinates of an image).
> > > This data is seperated by non important data let it be 'x'. E.g.
> > > x x x 2 4 6 8 x x x x 5 4 3 2 1 x x x x 6 5 4 3 7 6 8
> > > I need to select (2 & 8), (5 & 1) , (6 and 8) i.e. the first and last element of each set and store them seperately. Is there a way to do this using a Matlab function???
> > > Please these numbers are given as an example (each represents x,y coordinates)
> > >
> > > Regards
> > > Kenneth
> >
> > CSSM needs a working input/output example, not a verbose description...
> >
> > us
>
> Sorry if I'm not clear.
>
> What I have exactly is best grasping regions/coordinates of a polygon (i.e. linear sides) which can be of unequal lengths. These are being saved in an array and they are seperated by 'non important values e.g. 1000', which represent the corners.
> this is a woking example:
> group_threshold = 32
> selection = bwareaopen(grasping_regions~=-1000, group_threshold)
> selected_grasping_regions = grasping_regions .* selection
> selected_grasping_regions(selection == 0) = -1000
>
> Now I need to select these linear regions individually by taking their first and last element of each set in order to draw its line and then take a normal vector to it to analyse further.
>
> Regards
> Kenneth

not quite there, yet...
- this snippet does not run if copy/pasted because CSSMers don't have the data...
- CSSMers don't care about verbose details re your particular project (they come
from very different fields, have very different backgrounds)...
- ALL CSSMers care about is to solve a small i/o problem using ML (-syntax)...
afterwards, it's the OP's task to put it back into his/her app...

therefor, your question should look like this

% i have
x=pi; % <- bad data marker...
v=[x x 2 3 4 x 1 1 2 x x x x 4];
% i need
% ...

us
From: Kenneth Galea on
"us " <us(a)neurol.unizh.ch> wrote in message <hp6pu9$dhf$1(a)fred.mathworks.com>...
> "Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hp6nod$f3n$1(a)fred.mathworks.com>...
> > "us " <us(a)neurol.unizh.ch> wrote in message <hp6mis$sgh$1(a)fred.mathworks.com>...
> > > "Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hp6lss$jm3$1(a)fred.mathworks.com>...
> > > > Hi everyone.
> > > >
> > > > I have a 2dimensional array having certain important data (x-y coordinates of an image).
> > > > This data is seperated by non important data let it be 'x'. E.g.
> > > > x x x 2 4 6 8 x x x x 5 4 3 2 1 x x x x 6 5 4 3 7 6 8
> > > > I need to select (2 & 8), (5 & 1) , (6 and 8) i.e. the first and last element of each set and store them seperately. Is there a way to do this using a Matlab function???
> > > > Please these numbers are given as an example (each represents x,y coordinates)
> > > >
> > > > Regards
> > > > Kenneth
> > >
> > > CSSM needs a working input/output example, not a verbose description...
> > >
> > > us
> >
> > Sorry if I'm not clear.
> >
> > What I have exactly is best grasping regions/coordinates of a polygon (i.e. linear sides) which can be of unequal lengths. These are being saved in an array and they are seperated by 'non important values e.g. 1000', which represent the corners.
> > this is a woking example:
> > group_threshold = 32
> > selection = bwareaopen(grasping_regions~=-1000, group_threshold)
> > selected_grasping_regions = grasping_regions .* selection
> > selected_grasping_regions(selection == 0) = -1000
> >
> > Now I need to select these linear regions individually by taking their first and last element of each set in order to draw its line and then take a normal vector to it to analyse further.
> >
> > Regards
> > Kenneth
>
> not quite there, yet...
> - this snippet does not run if copy/pasted because CSSMers don't have the data...
> - CSSMers don't care about verbose details re your particular project (they come
> from very different fields, have very different backgrounds)...
> - ALL CSSMers care about is to solve a small i/o problem using ML (-syntax)...
> afterwards, it's the OP's task to put it back into his/her app...
>
> therefor, your question should look like this
>
> % i have
> x=pi; % <- bad data marker...
> v=[x x 2 3 4 x 1 1 2 x x x x 4];
> % i need
> % ...
>
> us

Ok, sorry. This will be similar to my first question!!!
I 'll use your code snippet now to explain better :)
i have
x=pi; % <- bad data marker...
v=[x x 2 3 4 x 1 1 2 8 x x x x 4 5 8 9];
% i need to have outputs (2&4) (1&8) (4&9) i.e. the first and last element of each set.

Regards
Kenneth