How to create a database in Mathematica

In summary, the conversation discusses the creation of a database or matrix in Mathematica to store solutions for a system of non-linear equations. The individual is looking for a way to create a blank variable of the matrix type and then append rows or records to it as needed. The solution involves creating an empty list for the database, constructing new rows for the database, and using [[]] to extract elements from the database.
  • #1
NRedacted
8
0
Hi All,

I have to solve a system of non-linear equations for a wide range of parameter space. I'm using FindRoot which is sensitive to initial conditions so I have to do it by hand and by trial and error and plotting, rather than putting the equations in a loop or in a table.

So what I want to do is create a databse or a Matrix with a fixed number of columns but variable number of rows so I can keep appending it with new results as and when I solve for them.

I've looked at a few mathematica books and their online reference but they only teach me how to create a table or a matrix already filled with some numbers or text or functions. What I want to create is a blank variable of the matrix type to which I can keep adding more and more rows (or records) and my database develops to add my solutions for the varying parameter space. Can someone please tell me how I can create a matrix type variable, declare it to be a matrix and then at my own leisure append rows or records to it.

Thanks a lot
N
 
Physics news on Phys.org
  • #2
Create an empty list for your database.
Then construct a new row for the database, perhaps using Solve or other methods.
Join your new row with your database.
Use [[]] to extract elements from your database.

In[30]:= database={};
In[31:= newrow={1,2,5,4,3,7,1,1,1,1};
In[32]:= database=Join[database,{newrow}]
Out[32]= {{1,2,5,4,3,7,1,1,1,1}}

In[33]:= newerrow={1,2,3,4,5,6,7,8,9,10};
In[34]:= database=Join[database,{newerrow}]
Out[34]= {{1,2,5,4,3,7,1,1,1,1},{1,2,3,4,5,6,7,8,9,10}}

In[35]:= database[[2,9]]
Out[35]= 9
 

1. How do I start creating a database in Mathematica?

To start creating a database in Mathematica, you will need to first open a new notebook. Then, you can use the DatabaseLink` package to connect to a database and start creating tables and adding data.

2. Can I import existing data into my Mathematica database?

Yes, you can import existing data into your Mathematica database using the Import function. This function allows you to import data from a variety of file formats, such as CSV, JSON, and Excel.

3. How can I query my Mathematica database?

You can query your Mathematica database using the SQLSelect function. This function allows you to specify which columns and rows you want to retrieve from your database.

4. Is there a limit to the size of a database in Mathematica?

No, there is no specific limit to the size of a database in Mathematica. However, the performance of your database may be affected if it becomes too large.

5. Can I share my Mathematica database with others?

Yes, you can share your Mathematica database with others by exporting it as a file or using the DatabaseLink` package to connect to a shared database. You can also use cloud services like Wolfram Cloud to collaborate and share your database with others.

Similar threads

Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Programming and Computer Science
2
Replies
50
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Precalculus Mathematics Homework Help
Replies
10
Views
619
  • Programming and Computer Science
Replies
4
Views
329
  • Programming and Computer Science
Replies
7
Views
424
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
10K
Back
Top