|
"antonio ferreira" <edgar.acferreira@gmail.com> wrote in message <ic3gvg$1h0$1@fred.mathworks.com>...
> "Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ic3gia$3qe$1@fred.mathworks.com>...
> > "antonio ferreira" <edgar.acferreira@gmail.com> wrote in message <ic3fm8$qip$1@fred.mathworks.com>...
> > > Hi all.
> > > I have two simple matrix a=[1 2;3 4; 5 6; 7 8] and b=[1 10; 5 6; 8 9; 10 10]. I need to create two sub-matrix until the first 5 in the first column and I am not being able to do this. The problem for me is that the number 5 changes from place in matrix a and b. Basically the result should be a sub-matrix c= [1 2;3 4; 5 6] and a submatrix d=[1 10; 5 6]. Could anyone give me a help please?Regards
> >
> > Like this:
> > c = a(1:find(a(:,1)==5),:)
> > ?
>
> Exactly.Many thanks
You probably want the 'first' argument in find coupled with 1 returned index; in case there are multiple 5s.
c = a(1:find(a(:,1)==5,1,'first'),:)
|