Home > Archive > Matlab > January 2008 > Find row
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| shapper 2008-01-31, 8:28 pm |
| Hello,
I have a structure with 3 fields:
id, name, comment
And I have an array of this structure with around 2000 rows.
Given an ID I want to find and remove the row that has that ID. How
can I do this?
Thanks,
Miguel
| |
|
| shapper <mdmoura@gmail.com> wrote in message <85d46d18-b360-
4c66-9827-eadfe7572a9a@v29g2000hsf.googlegroups.com>...
> Hello,
>
> I have a structure with 3 fields:
> id, name, comment
>
> And I have an array of this structure with around 2000
rows.
>
> Given an ID I want to find and remove the row that has
that ID. How
> can I do this?
>
> Thanks,
> Miguel
Like this:
% example data
s(1).id = 1 ; s(1).name = 'a' ;
s(2).id = 2 ; s(2).name = 'b' ;
s(3).id = 3 ; s(3).name = 'c' ;
% the engine (can be one statement)
ids = [s.id] ;
s(ids==2) = [] ;
hth
Jos
|
|
|
|
|