Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: ReplacePart
Replies: 4   Last Post: Sep 15, 2013 7:04 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 895
Registered: 10/29/11
Re: ReplacePart
Posted: Sep 15, 2013 7:04 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


{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@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
>
>
>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.