Deleting cell elements with a(x) = [];

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Deleting cell elements with a(x) = [];

David Bateman-3
One of the things on Johns todo list for octave 3.0 was deleting
cell array elements with a syntax like "a(x) = []". Checking against
a matlab R12 version I find the following behaviour...

>> a = cell(1,3); a{1} = 1; a{2} = 2; a{3} = 3, a{2} = [], a(2) = []  

a =

    [1]    [2]    [3]


a =

    [1]     []    [3]


a =

    [1]    [3]


So that is indexing a cell array with "{}" and passing an empty RHS
results in a empty matrix inserted into the cell array, while doing the
same thing while indexing with "()" deletes the element of the array.

The fact is this is quite trivial to implement in octave, as the following
patch shows. After applying this patch I get the following behaviour

octave:1> a = cell(1,3); a{1} = 1; a{2} = 2; a{3} = 3, a{2} = [], a(2) = []
a =

{
  [1,1] = 1
  [1,2] = 2
  [1,3] = 3
}

a =

{
  [1,1] = 1
  [1,2] = [](0x0)
  [1,3] = 3
}

a =

{
  [1,1] = 1
  [1,2] = 3
}


Regards
David


--
David Bateman                                [hidden email]
Motorola CRM                                 +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

changelog-cell20040825 (150 bytes) Download Attachment
patch.cell20040825 (713 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Deleting cell elements with a(x) = [];

John W. Eaton-6
On 25-Aug-2004, David Bateman <[hidden email]> wrote:

| The fact is this is quite trivial to implement in octave, as the following
| patch shows. After applying this patch I get the following behaviour

I applied the patch.

Thanks,

jwe