MathGroup Archive 2004

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

Search the Archive

Re: Assigning elements to a matrix

  • To: mathgroup at
  • Subject: [mg47370] Re: Assigning elements to a matrix
  • From: Jens-Peer Kuska <kuska at>
  • Date: Wed, 7 Apr 2004 03:16:28 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <c4u3ko$9lq$>
  • Reply-to: kuska at
  • Sender: owner-wri-mathgroup at



fullAssign[m_,{i_?Integer,j_?Integer,val_}]:= m[[i,j]]=val


say your list is lst and your matrix is m


fullAssign[m,#] & /@ lst;


m=SparseArray[sparseAssign /@ lst]

will do it.


Mark Coleman wrote:
> Greetings,
> I need to create a series of n x n matrices, in both conventional and
> sparse matrix formats. I have a (large) table of lists, where each list
> is of the form:
> {i,j,value}, where {i,j} are the row-column indices and value is the
> corresponding numerical value, i.e., m[[i,j]]=value.
> Using this data I need to create an n x n matrix where all the values
> except those specified in my list are 0. I would also like to create a
> similar matrix, this time using Mathematica's built-in SpareMatrix format.
> Can anyone suggest a way to do this?
> Thanks,
> -mark

  • Prev by Date: Re: problems with FindRoot: what worked with 4.2 does not work with 5.0
  • Next by Date: Re: Mathematical character sets
  • Previous by thread: Re: Assigning elements to a matrix
  • Next by thread: Scientific Notation in ListPlot Axes