|
ade77 wrote:
...[top posting repaired...please don't do that]...
> "Kishore " <kishore3385@yahoo.co.in> wrote in message <hcqep5$f8g$1@fred.mathworks.com>...
...
>> I would want to know if there is any command by which i can copy a
>> sub matrix from a matrix.
...
>>
>> In the above matrix, i need to copy all elements which are greater
>> than 1,to some matrix,( i.e i do no want the row 1.0e-2.....
>>
>> This can ofcourse be done in a loop,but is there any command
>> which simplifies the process? >>
>> I used bsxfun() ,but it doesnt seem to have this feature.
>>
...
> type doc find. or help find.
> the 'find' function will return the indicies of the elements or rows
> that meet your conditions.
> Then pass the indicies back to your sub array.
Better yet, look up and read about
"logical addressing"
B=A(A>1);
Note however, your example matrix and your description of what you want
aren't quite consonant--saving the elements >1 will eliminate at least a
couple of entries in A that are identically one, not just the row w/
values <1.
If that's what you want precisely, for the sample A you would need
B=A(A>=1);
Also note that there will be a question to decide on what the shape of
the resultant will be--the above will return a column vector which you
can reshape() as desired if necessary.
--
|