ReplacePart -> eliminate
- To: mathgroup at smc.vnet.net
- Subject: [mg131656] ReplacePart -> eliminate
- From: "Brambilla Roberto Luigi (RSE)" <Roberto.Brambilla at rse-web.it>
- Date: Mon, 16 Sep 2013 05:27:02 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
I'd like to eliminate the Indeterminate (or other non-numerical terms, as Infinite, etc...) items. Es. x = {-1.25664, 0.628319, -0.628319, 1.25664, Indeterminate, -1.25664, 0.628319, -0.628319, 1.25664, Indeterminate}; or x=Table[1/(3 - n), {n, 0, 5}]) {1/3, 1/2, 1, ComplexInfinity, -1,-1/2} How can I do it with a simple command? Many thanks, Roberto -----Messaggio originale----- Da: Bob Hanlon [mailto:hanlonr357 at gmail.com] Inviato: domenica 15 settembre 2013 13:06 A: mathgroup at smc.vnet.net Oggetto: Re: ReplacePart {5,10} is apparently interpreted as a position within an array rather than a list of positions. Not sure why the algorithm isn't able to resolve the ambiguity given that the input is a simple list. Or why there is no error stating that position {5,10} does not exist. x = {-1.25664, 0.628319, -0.628319, 1.25664, Indeterminate, -1.25664, 0.628319, -0.628319, 1.25664, Indeterminate}; x2 = x /. Indeterminate -> 0 {-1.25664, 0.628319, -0.628319, 1.25664, 0, -1.25664, 0.628319, -0.628319, \ 1.25664, 0} x2 == ReplacePart[x, {5 -> 0, 10 -> 0}] == ReplacePart[x, Thread[{5, 10} -> 0]] == ReplacePart[x, {{5} -> 0, {10} -> 0}] == ReplacePart[x, {{5}, {10}} -> 0] == ReplacePart[x, List= /@ {5, 10} -> 0] == ReplacePart[x, Position[x, Indeterminate] -> 0] True Bob Hanlon On Sat, Sep 14, 2013 at 6:02 AM, man21 <man21 at free.fr> wrote: > Hello, > > As a result of a calculation, I end up with a list of numerical values > which contains some "Indeterminate". > > x ={-1.25664, 0.628319, -0.628319, 1.25664, Indeterminate, -1.25664, > 0.628319, -0.628319, 1.25664, Indeterminate} > > I try to replace the "Indeterminate" by "0", using : > > ReplacePart[x, {5, 10} -> 0.] > > but this dosen't work. Any idea why, and how to do it ? > > Thanks, > > Michel > > > RSE SpA ha adottato il Modello Organizzativo ai sensi del D.Lgs.231/2001, in= forza del quale l'assunzione di obbligazioni da parte della Societ=E0 avvie= ne con firma di un procuratore, munito di idonei poteri. RSE adopts a Compliance Programme under the Italian Law (D.Lgs.231/2001). Ac= cording to this RSE Compliance Programme, any commitment of RSE is taken by= the signature of one Representative granted by a proper Power of Attorney.= Le informazioni contenute in questo messaggio di posta elettronica sono ris= ervate e confidenziali e ne e' vietata la diffusione in qualsiasi modo o for= ma. Qualora Lei non fosse la persona destinataria del presente messaggio, La= invitiamo a non diffonderlo e ad eliminarlo, dandone gentilmente comunicazi= one al mittente. The information included in this e-mail and any attachments= are confidential and may also be privileged. If you are not the correct rec= ipient, you are kindly requested to notify the sender immediately, to cancel= it and not to disclose the contents to any other person.