MathGroup Archive 1999

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

Search the Archive

Re: Protected element error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17280] Re: Protected element error
  • From: weber at math.uni-bonn.de (Matthias Weber)
  • Date: Fri, 30 Apr 1999 23:22:20 -0400
  • Organization: RHRZ - University of Bonn (Germany)
  • References: <7g0van$e8n@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <7g0van$e8n at smc.vnet.net>, Kristen Rounds
<krounds at accessone.com> wrote:

> Early in my program I define a 4x4 matrix:
> 
> A1x:=M.b1x.Transpose[M];
> 
> Later I wish to allow the user to modify a matrix element:
> 
> If[StringMatchQ[terma,"a33",IgnoreCase->True],
> "A"<>sur<>"x"[1,1]=Input["New a33 x value"]];
> 
> I am getting this error when I try to use the new A1x matrix:
> 
> SetDelayed::write: Tag StringJoin in A<>1<>x is Protected.
> 
> I tried to use Unprotect[A1x]; prior to the new input, but that
> doesn't seem to make a difference.
> 
> Please explain this error, and if there is a way to avoid it.  Thanks.
> 
> Kristen

I am not sure if there is a simpler way, but you could
write

Read[StringToStream["A"<>sur<>"x[1,1]=Input[\"New a33 x value\"]"]];

assuming that sur has some value.
In an assignment, the right hand side (rhs) is evaluated and assigned
to the unevaluated lhs. You can change this behaviour by
applying Evaluate to the lhs, but that would only result
in the attempt to assign the rhs to the string "A1x[1,1]".
I don't know off hand if there is also a way to convert the string to
a variable. My solution converts the whole command to an InputStream,
which is then read. 

Hope this helps.

Observe also that you will have problems with accessing *matrix* elements
this way: a[1,1] is an indexed variable, a[[1,1]] a list/matrix entry
(which is what you want).

Matthias


  • Prev by Date: How can I plot a file of <x, y, z> points?
  • Next by Date: Re: Mathematica 3.0 and Visual Basic
  • Previous by thread: Re: How can I plot a file of <x, y, z> points?
  • Next by thread: Re: Arciving data in Oracle to comma delimited values???