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 1999

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

Search the Archive

Replacing Part of a Matrix

  • To: mathgroup at
  • Subject: [mg20250] Replacing Part of a Matrix
  • From: flippy652 at
  • Date: Fri, 8 Oct 1999 18:30:22 -0400
  • Sender: owner-wri-mathgroup at

Hello all,

I have a n x n matrix, call it A.

I have a (n - 2)x(n - 2) matrix, call it B.

I would like to keep the outer rows and columns
of A, but repalce the inner rows and columns with
thos of B to get a new C.

I looked at the ReplacePart and other matrix and
list manipulation rules and couldn't quite find

I wrote a very gross module to do it.

Does anyone have such a module in Mathematica they would
like to share.

For example,

c = replace_a_b[a, b]

would return the desired result.


A = {{1,2,3,4},{5,6,7,8},{9,10,11,12},
B = {{20,30,},{40,50}}

C = replace_a_b[A,B], would produce:

C = {{1,2,3,4},{5,20,30,8},{9,40,50,12},

Basically, this function just replaces the
interior (n-2)x(n-2) in the larger matrix.

Can anyone help?

By the way, thank you to all who responded with
such an easy and useful rectangular grid

Thank you.

Wilson Figueroa
flip at

Sent via
Before you buy.

  • Prev by Date: Re: Re: NonlinearRegress and numerical functions...
  • Next by Date: Re: Drawing Rectangular Grid
  • Previous by thread: Re: V4.0 on NT4.0/SP3 does not update the Start/Documents List
  • Next by thread: Re: Replacing Part of a Matrix