Re: Matrix Manipulation
- To: mathgroup at smc.vnet.net
- Subject: [mg16461] Re: [mg16389] Matrix Manipulation
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Sat, 13 Mar 1999 02:22:00 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Here is one easy way do to this. First create the zero 3X3 matrix: In[34]:= A=Array[0&,{3,3}]; Next replace the the corresponding part of A by msub: In[35]:= A[[{1,3},{1,3}]]=msub; Now you can simply add A to mm to get what you wanted: In[36]:= mm+A Out[36]//MatrixForm= 22 2 25 4 5 6 30 8 33 On Thu, Mar 11, 1999, Andreas Paul Friedrich Bernhard <bernhard at eng.umd.e du> wrote: >I am trying to modify the elements of a submatrix in a matrix, without >having to replace each element explicitly > >for example: >mm = { {1,2,3}, {4,5,6}, {7,8,9} } >msub = { {21,22}, {23,24} } >I now wish to add the sub matrix: to positions (1,1),(1,3),(3,1),(3,3) > >I have tried using ReplacePart but it does not recognize the >multidimensional replacement, I have also tried >mm[ {{1,3} , {1,3}} ] = mm[ {{1,3} , {1,3}}] + msub > >but this crashes horribly > > >Thanks >AndyIII > >-- > ------- >What is man without the beasts, If all the beasts were gone, >Man would die from great loneliness of Spirit. >For whatever happens to the beasts, soon happens to man. - Chief Seattle > ------- > >**************************************************** >* Andreas P.F. Bernhard * >* Aerospace Department, University of Maryland * >* College Park, MD 20742 * >* bernhard at Glue.umd.edu * >* Fax: (301) 314-9001, Tel: (301) 405-1141 * >**************************************************** > > > Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp/ http://eri2.tuins.ac.jp/