Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Assigning elements to a matrix

  • To: mathgroup at
  • Subject: [mg47381] Re: Assigning elements to a matrix
  • From: "Gareth J. Russell" <gjr2008 at>
  • Date: Wed, 7 Apr 2004 03:16:42 -0400 (EDT)
  • Organization: Columbia University
  • References: <c4u3ko$9lq$>
  • Sender: owner-wri-mathgroup at

In <c4u3ko$9lq$1 at> 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


Have you looked at the documentation for SparseArray? If you convert 
each list from {i,j,value} to {{i,j}->value} and send the resulting 
table to SparseArray, you've done it.

Normal[mySparseArray] give you the full array equivalent.

It's all in the Help Browser...

Gareth Russell

Columbia University

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