MathGroup Archive 2006

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

Search the Archive

Re: setps problem/how to set matrix elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65854] Re: setps problem/how to set matrix elements
  • From: bghiggins at ucdavis.edu
  • Date: Wed, 19 Apr 2006 04:54:01 -0400 (EDT)
  • References: <e1vet0$9db$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Rob, I would use ReplacePart to avoid the error

FSD[r_, xdim_, ydim_] := Module[{}, ReplacePart[r, 5, {1, 1}]]

To see what is going on try this simpler problem:

b=(1,2)
myfunc[b_]:=b[[1]]=5

Now evaluate

Trace[myfunc[b]]

Here is a snippet of the output

{{b, {1, 2}}, myfunc[{1, 2}], {1, 2}[[1]] = 5, {Message[Set::setps, {1,
2}],....

During the evaluation b gets replaced with {1,2} so that Mathematica is
trying to evaluate {1,2}[[1]] and hence the reason for the error. If on
the other hand you evaluate

c={1,2}
Trace[c[[1]]=5]
{c[[1]] = 5, 5}


Hope this helps,

Cheers,

Brian


  • Prev by Date: Re: MathLink and Intel C++ Compiler
  • Next by Date: Re: Redefine Power
  • Previous by thread: Re: setps problem/how to set matrix elements
  • Next by thread: Need lower case in HTML save