MathGroup Archive 1999

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

Search the Archive

Re: problem with Part function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18199] Re: [mg18172] problem with Part function
  • From: "Wolf, Hartmut" <hwolf at debis.com>
  • Date: Mon, 21 Jun 1999 22:50:40 -0400
  • Organization: debis Systemhaus
  • References: <199906200354.XAA27513@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

Hello Dario,

Casubolo Dario schrieb:
> 
> Just a little problem:
> I've a matrix of zeros, say:
> mat=Table[Table[0,{5}],{5}];
> then, I've a point in xy axys,
> xy={3,3};
> now, I want the position {3,3} of matrix becomes 1;
> if I write
> mat[[xy]]=1; or mat[[{3,3}]]=1; it doesn't work; only mat[[3,3]]=1
> works, but I don't want rewrite all.

The Mathematica Function for doing what you want is

	ReplacePart[mat,1,xy]

If you want to taste syntactical sugar you have first to convert your
"point" object xy to a sequence:

	mat[[Sequence@@xy]]=1

regards, hw



  • Prev by Date: Re: Plotting discontinuous lines
  • Next by Date: Re: Inserting Adobe pdf files in ver. 4 notebooks
  • Previous by thread: problem with Part function
  • Next by thread: Re: problem with Part function