Re: Could we build matrix with codition instruction?
- To: mathgroup at smc.vnet.net
- Subject: [mg23331] Re: [mg23314] Could we build matrix with codition instruction?
- From: "Mark Harder" <harderm at ucs.orst.edu>
- Date: Tue, 2 May 2000 00:43:13 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Coase, Copy this and try it. In[5]:= Needs["LinearAlgebra`MatrixManipulation`"] In[12]:= M = UpperDiagonalMatrix[Function[x, 1], 4]; M // MatrixForm Out[13]//MatrixForm= \!\(\* TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"1", "1", "1", "1"}, {"0", "1", "1", "1"}, {"0", "0", "1", "1"}, {"0", "0", "0", "1"} }], "\[NoBreak]", ")"}], (MatrixForm[ #]&)]\) Look up the documentation for UpperDiagonalMatrix[] and you will see that the first argument is a function, and it need not be just a constant, allowing for variable UDM s. -mark -----Original Message----- From: Coase Yang <cnc at ms6.hinet.net> To: mathgroup at smc.vnet.net Subject: [mg23331] [mg23314] Could we build matrix with codition instruction? >Dear All: > >I want to construct an 4*4 upper triangular matrix with >conditional instruction, a[i,j]: >if j-i>=0, then a[[i,j]]=1 >if j-i<0, then a[[i,j]]=0 >Could anyone tell me how I could build this matrix with >list or Table form by conditional instruction inside? > >Thank you very much. > >Coase Yang >