Plotting Parameter t vs. e1 Values

  • Context: Mathematica 
  • Thread starter Thread starter jemma
  • Start date Start date
  • Tags Tags
    Parameter Plotting
Click For Summary
SUMMARY

The discussion centers on generating a single plot of parameter t against e1 values using Mathematica. The user initially employs a For loop to iterate through values of t, resulting in multiple graphs instead of a single combined plot. The recommended solution involves using ListPlot in conjunction with a table of values generated by Do or Table functions, which are more suitable for this type of plotting task.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of plotting functions such as ListPlot
  • Knowledge of iterative constructs like For, Do, and Table
  • Basic understanding of solving equations with NSolve
NEXT STEPS
  • Learn how to use the Do function in Mathematica for iterative tasks
  • Explore the Table function for generating lists of values in Mathematica
  • Study advanced plotting techniques in Mathematica, including combining multiple datasets
  • Investigate the use of NSolve for solving systems of equations in Mathematica
USEFUL FOR

Mathematica users, data analysts, and anyone interested in visualizing mathematical relationships through plotting in programming environments.

jemma
Messages
35
Reaction score
0
I would like to generate a plot displaying the parameter t on the x axis, varying from 0 to 0.95 and the corresponding values of e1. My code below does what I want (I think) but is plotting all the different points on different graphs (all 950 of them!). How can I get it to plot on the same graph? Thanks


For[i = 0, i ≤ 950, ++i,
ListPlot[e1 /. NSolve[{equ1 == 0, equ2 == 0, equ3 == 0}
/. t -> i/1000.0, {e1, e2, e3}]]]
 
Physics news on Phys.org
Make your table of values first, then use ListPlot.
With out details of your code (or, better yet, a simplified example that shows the same issues) it is not worth trying to give you working code.

As an aside: don't use For[] unless you really need to test for some condition to end the loop. It's probably best to use Do[] or Table[] for the above type of problem.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K