RE:Initialize a matrix in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg66763] RE:Initialize a matrix in mathematica
- From: Mark_robert.holt at kcl.ac.uk
- Date: Mon, 29 May 2006 06:06:18 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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]]