Mathematica Help with Table command and Matrix operations

In summary, the user is trying to generate data in a Table and perform mathematical operations on it. However, they are encountering issues with extra parentheses and are unable to multiply matrices. They are seeking assistance to remove the parentheses and make the multiplication work.
  • #1
Amatya
1
0
Hi,

I need to generate some data in a Table and then be able to do all kinds of matrix and other mathematical operations on them. Right now I am testing the commands but am unable to get them to work. My table has this extra parenthesis floating around which I'm not sure how to get rid of.

Code:
test = Table[{i^2, y /. Solve[2 y + i == 0]}, {i, 1, 10}]
Code:
 Out[8]={{1, {-(1/2)}}, {4, {-1}}, {9, {-(3/2)}}, {16, {-2}}, {25, {-(5/
    2)}}, {36, {-3}}, {49, {-(7/2)}}, {64, {-4}}, {81, {-(9/
    2)}}, {100, {-5}}}
Code:
test2 = {{1/2, 0}, {0, 1/2}}


Now I am unable to multiply the two Matrices, Test 2x10 and Test2 2x2. I have tried
Code:
test2.test
and also
Code:
test.test2
and neither command works. Also, Test has this additional set of parenthesis around the entries in the second column, for example like this:
Code:
{1, {-(1/2)}}
. I would like to be able to get rid of them if possible.. though I'm not sure if that messes anything up.

Any help will be greatly appreciated. Thanks a lot,
 
Physics news on Phys.org
  • #2
Replace your code with

Code:
test=Table[{i^2,y/.Solve[2 y+i==0][[1]]},{i,1,10}]
 

Related to Mathematica Help with Table command and Matrix operations

What is the Table command in Mathematica and how does it work?

The Table command in Mathematica is used to create a list of values based on a specified pattern. It takes in a function or expression, along with one or more iterators, and generates a table of values by substituting the iterator values into the expression. The resulting list can be used for further calculations or visualizations.

How can I use the Table command to create a matrix in Mathematica?

To create a matrix using the Table command, you can use nested iterators to specify the rows and columns of the matrix. For example, Table[i*j, {i, 1, 3}, {j, 1, 4}] will generate a 3x4 matrix with values ranging from 1 to 12. Alternatively, you can use the Array command, which is specifically designed for creating matrices and multi-dimensional arrays.

What are some common operations that can be performed on matrices in Mathematica?

Some common operations on matrices in Mathematica include addition, subtraction, multiplication, and transposition. You can also perform operations such as finding the determinant, inverse, and eigenvalues of a matrix. In addition, there are built-in functions for matrix manipulation and transformation, such as Flatten, Partition, and Map.

How can I access specific elements or rows/columns of a matrix in Mathematica?

To access specific elements of a matrix, you can use the double bracket notation, e.g. matrix[[i,j]], where i and j are the indices of the row and column, respectively. You can also use the Part function, which allows you to specify a range of elements or a list of indices to extract. Additionally, you can use the functions Take and Drop to select specific rows or columns from a matrix.

Are there any built-in functions in Mathematica for matrix visualization and manipulation?

Yes, there are many built-in functions in Mathematica for matrix visualization and manipulation. Some examples include MatrixPlot for visualizing matrices as heatmaps, ArrayPlot for visualizing multi-dimensional arrays, and MatrixForm for displaying matrices in a more traditional format. The Manipulate function can also be useful for dynamically visualizing and manipulating matrices.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
275
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
376
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
321
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
198
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
3
Views
541
Back
Top