Student Support Forum: 'Matrices and for loops' topicStudent Support Forum > General > "Matrices and for loops"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response Eric Harley 10/12/05 09:57am If I understand what you want, take a look at what this does: Clear[f, a, b, i, j]; A = Table[{i, j}, {j, 1, 3}, {i, 1, 10}] A // TraditionalForm f[a_, b_] := a + b; B = Table[f[i, j], {j, 1, 3}, {i, 1, 10}] B // TraditionalForm Hopefully that should be relatively self-explanatory. You can do a lot of things when you get comfortable with list manipulation in Mathematica, and you can basically view a matrix as a nested list. You can look up Table, List, //, and TraditionalForm in the help to get a better understanding of what is going on here. Note that a ; at the end of a line suppresses output. Leaving the ; off allows output to be generated. You can use lines like f[a_, b_] := a + b; to define functions. The underbars have to be there in the function definition for the definition to apply to any arguments you stick into f[,]. The : on the := is probably safest to keep there in function definitions if you don't understand what it does, although depending on what you're doing it might slow things down some. Also, the := has the side effect that you don't really need a ; to suppress output from this line. URL: ,

 Subject (listing for 'Matrices and for loops') Author Date Posted Matrices and for loops Ashesh 10/11/05 11:11pm Re: Matrices and for loops Eric Harley 10/12/05 09:57am Re: Matrices and for loops alvin 10/17/05 9:30pm Re: Matrices and for loops yehuda ben-s... 10/20/05 03:56am
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic