MathGroup Archive 2006

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

Search the Archive

RE:Initialize a matrix in mathematica


Dear Ashesh,
I hope/think this is what you are after:

In[3]:=
mat[ndiv_Integer,i_]:=
    Module[{tab},
      tab=Table[i^2,{ndiv},{ndiv}]
      ];

In[8]:=
mat[5,2]

Out[8]=
{{4,4,4,4,4},{4,4,4,4,4},{4,4,4,4,4},{4,4,4,4,4},{4,4,4,4,4}}

mat is the name of our defined function which can be reused for different values of ndiv (matrix dimensions) and i (to give a  ndiv*ndiv matrix with i^2 at each location).

Cheers,

Mark

Link to the forum page for this post:
http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Special:Forum_ViewTopic&pid=10693#p10693
Posted through http://www.mathematica-users.org [[postId=10693]]



  • Prev by Date: Re: x/x
  • Next by Date: Re: Initialize a matrix in mathematica
  • Previous by thread: Re: Initialize a matrix in mathematica
  • Next by thread: Re: Initialize a matrix in mathematica