How to do this in Mathematica?

  • Mathematica
  • Thread starter mikezburke
  • Start date
  • Tags
    Mathematica
In summary, the conversation was about using Mathematica to manipulate data from a text file and create a plot. The speaker was having trouble figuring out how to manipulate individual members in the data list and asked for help. The solution provided was to use list[[All,2]] to access all the second elements in the list.
  • #1
mikezburke
2
0
How to do this in Mathematica??

Hi - I am an engineering student who is quite new to Mathematica (v. 6) but I really enjoy it. Lots of examples, easy to just play and figure out how to do something for yourself. Makes beautiful output. However, I have not been able to figure this out...
I am using another program (COMSOL) which will export values from a graph as a text file - eg "Data.txt". I use list1 = ReadList["where_the_file_is_located/Data.txt", {Number, Number}] to read the date into a list. Then I use ListPlot[{list1}, PlotRange -> {0, as_big_as_I_need}] and it plots very nicely.
However, I cannot figure out how to manipulate individual members in my list (i.e. multiply all the x-values [the first "Number"] by something. How can I manipulate all the first or the second "Number(s)" in a list like this?

Thanks!
 
Physics news on Phys.org
  • #2


list[[All,2]] would give a list of all of the second elements
 
  • #3


Perfect thanks!
 

Related to How to do this in Mathematica?

1. How do I import data into Mathematica?

To import data into Mathematica, you can use the Import function. This function allows you to import various types of data, such as text files, images, and spreadsheets. You can also specify the format of the data you are importing. For example, if you want to import a CSV file, you can use the code: Import["file.csv", "CSV"].

2. How do I plot a graph in Mathematica?

To plot a graph in Mathematica, you can use the Plot function. This function takes in a mathematical expression or a list of points and plots it on a graph. You can also customize the appearance of the graph by specifying options such as the color, style, and labels. For example, to plot the function y = x^2 with a red line, you can use the code: Plot[x^2, {x, 0, 5}, PlotStyle -> Red].

3. How do I manipulate and analyze data in Mathematica?

Mathematica has a wide range of built-in functions for data manipulation and analysis. For example, you can use the Mean, Median, and StandardDeviation functions to calculate basic statistics on a dataset. You can also use functions like Select and Sort to filter and sort your data. Additionally, Mathematica has powerful visualization tools that can help you analyze your data visually.

4. How do I write a loop in Mathematica?

In Mathematica, you can use the Do or For loop to iterate through a set of instructions multiple times. The syntax for these loops is similar to other programming languages, but Mathematica also has its own unique looping functions like Table and Map. These functions allow you to perform operations on elements of a list or range of numbers without explicitly using a loop.

5. How do I export my results from Mathematica?

To export your results from Mathematica, you can use the Export function. This function allows you to save your data or graphs in various formats, such as PDF, PNG, or CSV. You can also specify the dimensions and resolution of your exported file. For example, to export a plot as a high-resolution PNG file, you can use the code: Export["plot.png", Plot[x^2, {x, 0, 5}], ImageResolution -> 300].

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
501
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
340
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Precalculus Mathematics Homework Help
Replies
6
Views
696
Back
Top