MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Replacing a part of a list/matrix?

  • To: mathgroup at
  • Subject: [mg2193] Re: Replacing a part of a list/matrix?
  • From: ianc (Ian Collier)
  • Date: Fri, 13 Oct 1995 02:25:02 -0400
  • Organization: Wolfram Research, Inc.

In article <45d22j$63m at>, olee at (O. Lee) wrote:

> I am trying to assign a value to a matrix position, such as:
>         pop[[ x,y ]] = value
> in a module function. When I try manually assigning a value
> to the matrix position outside of the module, it works. When
> I run the function with the statement, Mathematica gives me
> the following error message:
> Part::setps:
>         {{1, 1, 0, 0}, <<1>>}
>           in assignment of part is not a symbol.
> Can anyone tell me how to get the assignment statement to
> work! I isolated the problem in the function to this line
> and I am sure that what I just described was the problem.
> I have tried using the command:
>         pop=ReplacePart[pop,value,{x,y}]
> but it gives me even more error messages! Help me please!
> I appreciate any help. Thanks.
> O. Lee

ReaplacePart is the way to do this. It workes in this example:

    mat = {{a,b},{c,d}}
    {{a, b}, {c, d}}
    mat = ReplacePart[ mat, 4, {1,2}]
    {{a, 4}, {c, d}}
    {{a, 4}, {c, d}}

I am not sure what happened in your case - without seeing the exact
messages it is hard to tell.

I hope this helps.


Ian Collier
Technical Sales Support
Wolfram Research, Inc.
tel:(217)-398-0700     fax:(217)-398-0747      ianc at
Wolfram Research Home Page:   

  • Prev by Date: Re: Q: ROTATING ANIMATIONS in MMA?
  • Next by Date: Re: Help on mathieu equation needed
  • Previous by thread: Re: Replacing a part of a list/matrix?
  • Next by thread: Re: Replacing a part of a list/matrix?