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 2001

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

Search the Archive

Re: Special Matrix

  • To: mathgroup at
  • Subject: [mg28242] Re: Special Matrix
  • From: "Souvik Banerjee" <s-banerjee at>
  • Date: Fri, 6 Apr 2001 01:52:51 -0400 (EDT)
  • Organization: Northwestern University, Evanston, IL, US
  • References: <9ah5nq$>
  • Sender: owner-wri-mathgroup at

Not sure if the shortest but it works:

CreateMatrix[n_] :=
    r = ZeroMatrix[1, n]; m = Table[1, {n - 2}, {n - 2}];
    c = ZeroMatrix[n - 2, 1];
    BlockMatrix[{{r}, {c, m, c}, {r}}]

The bottleneck seems to be the Table[] operations. If there is a built in
function to create a matrix with a constant element then it will speed this


Yoram Pollack <syftech at> wrote in message
news:9ah5nq$ps0 at
> Hello
> I am trying to create a "n x n" matrix with "1" in every position exept in
> first and last row, and first and last coulumn, where "0" is needed. In
> other words: sqare matrix full of  "1" sorounded by "0".
> What will be the fastest and shortest way to do it?
> Thanks
> Yoram

  • Prev by Date: Re: Automatic expansion of Log[a^n] for a, n explicit positive integers?
  • Next by Date: Manipulating Strings
  • Previous by thread: Re: Special Matrix
  • Next by thread: Re: Special Matrix