How to create a database in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter NRedacted
  • Start date Start date
  • Tags Tags
    Database Mathematica
Click For Summary
SUMMARY

This discussion focuses on creating a dynamic database in Mathematica to store results from solving non-linear equations using the FindRoot function. The user seeks to establish a matrix with a fixed number of columns and a variable number of rows, allowing for the appending of new results. The solution involves initializing an empty list for the database, constructing new rows, and using the Join function to append these rows to the existing database. Example code snippets demonstrate the process of creating and updating the database effectively.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of matrix operations in Mathematica
  • Basic knowledge of non-linear equations and the FindRoot function
  • Experience with list manipulation in Mathematica
NEXT STEPS
  • Explore Mathematica's Join function for advanced list operations
  • Learn about dynamic data structures in Mathematica
  • Investigate the use of Solve for generating new rows in a database
  • Study best practices for managing large datasets in Mathematica
USEFUL FOR

Mathematica users, researchers solving non-linear equations, and anyone interested in dynamic data management within Mathematica.

NRedacted
Messages
7
Reaction score
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
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
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
10K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K