From: Niles on 4 Aug 2010 07:40 Hi I have a table, where all the entries containing the integer "0" are redundant, i.e. these entries must be removed. I cannot seem to find a WHERE-command like the one in another system. Is there a smart way of doing this in Mathematica? Best, Niles.
From: Albert Retey on 4 Aug 2010 08:20 Hi, > I have a table, where all the entries containing the integer "0" are > redundant, i.e. these entries must be removed. I cannot seem to find a > WHERE-command like the one in another system. Is there a smart way of doing > this in Mathematica? Well, Mathematica isn't a clone of another system, whatever that might be, so you will unfortunatly have to learn to do things the "Mathematica" way. From what you describe DeleteCases[yourlist,0,Infinity] most probably will do what you want, but I'm not sure. You could also look at the documentation for Cases and Select or Pick which provide similar possibilities to select parts of a list or array. hth, albert
From: prashanth on 5 Aug 2010 07:00 On Aug 4, 5:20 pm, Albert Retey <a...(a)gmx-topmail.de> wrote: > Hi, > > > I have a table, where all the entries containing the integer "0" are > > redundant, i.e. these entries must be removed. I cannot seem to find a > > WHERE-command like the one in another system. Is there a smart way of doing > > this in Mathematica? You can use the following: Select[table,Abs[#]>0&] The Abs[#] takes care to not delete negative numbers that may be present in your table. if sure that there are no negative numbers in your table, you can use : Select[table,#>0&]
From: Themis Matsoukas on 6 Aug 2010 06:54 MyList = {-1, 0, -2, 0, 1, 0, 2, 0, 3, 0, 4, 0} {-1, 0, -2, 0, 1, 0, 2, 0, 3, 0, 4, 0} Select[MyList, # != 0 &] {-1, -2, 1, 2, 3, 4} Themis
|
Pages: 1 Prev: Can't get Mathematica to evaluate correctly a Next: Save a notebook state |