MathGroup Archive 1995

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

Search the Archive

Re: Replacing a part of a list/matrix?

  • Subject: [mg2193] Re: Replacing a part of a list/matrix?
  • From: ianc (Ian Collier)
  • Date: Fri, 13 Oct 1995 06:25:02 GMT
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at wri.com ( )

In article <45d22j$63m at ralph.vnet.net>, olee at ripco.com (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:

In[9]:=
    mat = {{a,b},{c,d}}
Out[9]=
    {{a, b}, {c, d}}
In[11]:=
    mat = ReplacePart[ mat, 4, {1,2}]
Out[11]=
    {{a, 4}, {c, d}}
In[12]:=
    mat
Out[12]=
    {{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

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


  • Prev by Date: Re: What am I doing wrong?
  • Next by Date: Re: Q: ROTATING ANIMATIONS in MMA?
  • Previous by thread: Replacing a part of a list/matrix?
  • Next by thread: Re: Replacing a part of a list/matrix?