MathGroup Archive 2000

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

Search the Archive

Re: Could we build matrix with codition instruction?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23347] Re: [mg23314] Could we build matrix with codition instruction?
  • From: Matt.Johnson at autolivasp.com
  • Date: Thu, 4 May 2000 02:59:15 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com


This may not be the most eloquent way, but

In[53]:=
mat = Array[f, {4, 4}]

Out[53]=
{{f[1, 1], f[1, 2], f[1, 3], f[1, 4]}, {f[2, 1], f[2, 2], f[2, 3],
    f[2, 4]}, {f[3, 1], f[3, 2], f[3, 3], f[3, 4]}, {f[4, 1], f[4, 2],
    f[4, 3], f[4, 4]}}

In[57]:=
g[i_, j_] := If[(j - i) >= 0, mat[[i, j]] = 1, mat[[i, j]] = 0]

In[62]:=
Table[g[i, j], {i, 4}, {j, 4}]

Out[62]=
{{1, 1, 1, 1}, {0, 1, 1, 1}, {0, 0, 1, 1}, {0, 0, 0, 1}}

In[61]:=
mat

Out[61]=
{{1, 1, 1, 1}, {0, 1, 1, 1}, {0, 0, 1, 1}, {0, 0, 0, 1}}

-matt






Coase Yang <cnc at ms6.hinet.net> on 05/01/2000 04:00:15 PM

Subject: [mg23347]  [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







  • Prev by Date: Re: Fit with constraints?
  • Next by Date: Question: Fitting numerical solutions of ord. diff. equ.
  • Previous by thread: RE: Could we build matrix with codition instruction?
  • Next by thread: Re: Transparency in 3D Graphics?