From: us on
"Cyberbrain " <afatnassi(a)hotmail.com> wrote in message <huvurt$44l$1(a)fred.mathworks.com>...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <huvu5d$kfd$1(a)fred.mathworks.com>...
> > "Fatnassi " <afatnassi(a)hotmail.com> wrote in message <huvsgt$9l4$1(a)fred.mathworks.com>...
> > > Hi everybody,
> > > I´m looking for a compact way to localize a row in a matrix
> > > deleting that row and reshaping the matrix..! to a new one without the found row..!
> > > The problem is has to be compact cause it will be a part of a very long script with GUI and i have to spare some ram ...so solution with loops ...will not solve my problem..
> > >
> > > Thunks..!
> >
> > Hi Fatnassi, The best way depends on the entries in the matrix. For example, find() may work well in some instances and not in others. I think you should give us a little more detail on what characteristics the particular row has, or rows have, that you wish to delete.
> >
> > Wayne
>
>
> Thunks for your answer...!
> I just need to delete a row from a matrix...! so this is what i meant.. :
>
> x=[l c]
> M=[1 2;5 7;46 44;45 35]
> x is of course a variable vector and i want to find out if that row is defined
> in my matrix M and if yes than delete it and reshape the matrix M..!
>
> Thunks!

be more clear...
what are L/C in your X(?)...
show an example, which makes sense...

us
From: Cyberbrain on
"us " <us(a)neurol.unizh.ch> wrote in message <huvv7n$qcd$1(a)fred.mathworks.com>...
> "Cyberbrain " <afatnassi(a)hotmail.com> wrote in message <huvurt$44l$1(a)fred.mathworks.com>...
> > "Wayne King" <wmkingty(a)gmail.com> wrote in message <huvu5d$kfd$1(a)fred.mathworks.com>...
> > > "Fatnassi " <afatnassi(a)hotmail.com> wrote in message <huvsgt$9l4$1(a)fred.mathworks.com>...
> > > > Hi everybody,
> > > > I´m looking for a compact way to localize a row in a matrix
> > > > deleting that row and reshaping the matrix..! to a new one without the found row..!
> > > > The problem is has to be compact cause it will be a part of a very long script with GUI and i have to spare some ram ...so solution with loops ...will not solve my problem..
> > > >
> > > > Thunks..!
> > >
> > > Hi Fatnassi, The best way depends on the entries in the matrix. For example, find() may work well in some instances and not in others. I think you should give us a little more detail on what characteristics the particular row has, or rows have, that you wish to delete.
> > >
> > > Wayne
> >
> >
> > Thunks for your answer...!
> > I just need to delete a row from a matrix...! so this is what i meant.. :
> >
> > x=[l c]
> > M=[1 2;5 7;46 44;45 35]
> > x is of course a variable vector and i want to find out if that row is defined
> > in my matrix M and if yes than delete it and reshape the matrix M..!
> >
> > Thunks!
>
> be more clear...
> what are L/C in your X(?)...
> show an example, which makes sense...
>
> us


ok..! for example for the case that
x=[46 44]
M=[1 2;5 7;46 44;45 35]
in this case i want to get the new M=[1 2;5 7;45 35]

and for the case that x=[46 7] (notice that the two elements are in my matrix
but i need to find out if the whole row x is in the matrix or not..!)
M stills the same..!
thunks!
From: us on
"Cyberbrain " <afatnassi(a)hotmail.com> wrote in message <huvvm5$o2a$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <huvv7n$qcd$1(a)fred.mathworks.com>...
> > "Cyberbrain " <afatnassi(a)hotmail.com> wrote in message <huvurt$44l$1(a)fred.mathworks.com>...
> > > "Wayne King" <wmkingty(a)gmail.com> wrote in message <huvu5d$kfd$1(a)fred.mathworks.com>...
> > > > "Fatnassi " <afatnassi(a)hotmail.com> wrote in message <huvsgt$9l4$1(a)fred.mathworks.com>...
> > > > > Hi everybody,
> > > > > I´m looking for a compact way to localize a row in a matrix
> > > > > deleting that row and reshaping the matrix..! to a new one without the found row..!
> > > > > The problem is has to be compact cause it will be a part of a very long script with GUI and i have to spare some ram ...so solution with loops ...will not solve my problem..
> > > > >
> > > > > Thunks..!
> > > >
> > > > Hi Fatnassi, The best way depends on the entries in the matrix. For example, find() may work well in some instances and not in others. I think you should give us a little more detail on what characteristics the particular row has, or rows have, that you wish to delete.
> > > >
> > > > Wayne
> > >
> > >
> > > Thunks for your answer...!
> > > I just need to delete a row from a matrix...! so this is what i meant.. :
> > >
> > > x=[l c]
> > > M=[1 2;5 7;46 44;45 35]
> > > x is of course a variable vector and i want to find out if that row is defined
> > > in my matrix M and if yes than delete it and reshape the matrix M..!
> > >
> > > Thunks!
> >
> > be more clear...
> > what are L/C in your X(?)...
> > show an example, which makes sense...
> >
> > us
>
>
> ok..! for example for the case that
> x=[46 44]
> M=[1 2;5 7;46 44;45 35]
> in this case i want to get the new M=[1 2;5 7;45 35]
>
> and for the case that x=[46 7] (notice that the two elements are in my matrix
> but i need to find out if the whole row x is in the matrix or not..!)
> M stills the same..!
> thunks!

one of the many solutions

m=[
1 44
2 3
44 45
45 44
4 5
];
x=[44,45];
ix=ismember(m,x,'rows'),2;
m(ix,:)=[]
%{
% ans =
1 44
2 3
45 44 % <- note: same numbers but diff order...
4 5
%}

us
From: Cyberbrain on
Dude that´s exactly the compact solution that i´m looking for ...!
Thunks...!
From: Wayne King on
"Cyberbrain " <afatnassi(a)hotmail.com> wrote in message <huvvm5$o2a$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <huvv7n$qcd$1(a)fred.mathworks.com>...
> > "Cyberbrain " <afatnassi(a)hotmail.com> wrote in message <huvurt$44l$1(a)fred.mathworks.com>...
> > > "Wayne King" <wmkingty(a)gmail.com> wrote in message <huvu5d$kfd$1(a)fred.mathworks.com>...
> > > > "Fatnassi " <afatnassi(a)hotmail.com> wrote in message <huvsgt$9l4$1(a)fred.mathworks.com>...
> > > > > Hi everybody,
> > > > > I´m looking for a compact way to localize a row in a matrix
> > > > > deleting that row and reshaping the matrix..! to a new one without the found row..!
> > > > > The problem is has to be compact cause it will be a part of a very long script with GUI and i have to spare some ram ...so solution with loops ...will not solve my problem..
> > > > >
> > > > > Thunks..!
> > > >
> > > > Hi Fatnassi, The best way depends on the entries in the matrix. For example, find() may work well in some instances and not in others. I think you should give us a little more detail on what characteristics the particular row has, or rows have, that you wish to delete.
> > > >
> > > > Wayne
> > >
> > >
> > > Thunks for your answer...!
> > > I just need to delete a row from a matrix...! so this is what i meant.. :
> > >
> > > x=[l c]
> > > M=[1 2;5 7;46 44;45 35]
> > > x is of course a variable vector and i want to find out if that row is defined
> > > in my matrix M and if yes than delete it and reshape the matrix M..!
> > >
> > > Thunks!
> >
> > be more clear...
> > what are L/C in your X(?)...
> > show an example, which makes sense...
> >
> > us
>
>
> ok..! for example for the case that
> x=[46 44]
> M=[1 2;5 7;46 44;45 35]
> in this case i want to get the new M=[1 2;5 7;45 35]
>
> and for the case that x=[46 7] (notice that the two elements are in my matrix
> but i need to find out if the whole row x is in the matrix or not..!)
> M stills the same..!
> thunks!

Hi, I think in your case:

[C,IA,IB] = intersect(M,x,'rows');
M(IA,:) = [];

would work.

Wayne