Plotting Centroid Energy & Distance In Air in Mathematica

In summary, the conversation discusses the process of plotting two lists of data in Mathematica. The recommended method is to transpose the two lists and use ListPlot, but there is an error due to the arrays having different lengths. The conversation also mentions that the topic is related to a homework assignment.
  • #1
cepheid
Staff Emeritus
Science Advisor
Gold Member
5,199
38
Hello:

I have entered data into two lists in Mathematica:

centroidEnergy = {1.3485, 1.4780,
1.6176, 1.7820, 1.9123, 2.0274, 2.1635, 2.3163, 2.4213, 2.5191, 2.6515, \
2.7490, 2.8763, 2.9894, 3.0728, 3.1949, 3.2816, 3.3923, 3.4773, 3.5884, \
3.6804, 3.7702, 3.8374, 3.9679, 4.0507, 4.1507, 4.2163, 4.3145, 4.4039, \
4.5056, 4.5089, 4.6440, 4.7331, 4.8497, 4.9290, 5.0019, 5.0862, 5.1815, \
5.2427, 5.3365, 5.4225, 5.4800}


and

distanceInAir = {2.0523, 2.0020,
1.9517, 1.8964, 1.8511, 1.8008, 1.7505, 1.7002, 1.6499, 1.5996,
1.5493, 1.4990, 1.4488, 1.3984, 1.3481, 1.2979, 1.2476, 1.1520,
1.0967, 1.0464, 0.99606, 0.95079,
0.89546, 0.84516, 0.79486, 0.74456, 0.69426, 0.64396, 0.59366,
0.54336, 0.49306, 0.44276, 0.39247, 0.34217, 0.29186, 0.24157,
0.19269, 0.14097, 0.090671, 0.040371, 0.000132}

I am trying to plot the former vs. the later. The recommended method I have seen to do so is to Transpose the two lists to that M. creates a list of ordered pairs of corresponding items from each one. Then, ListPlot that. However, I can't get the following command to work: it always gives the ensuing error message:

dataToPlot = Transpose[{distanceInAir, centroidEnergy}]

Transpose :: nmtx :: the first two levels of the one-dimensional list {{2.0523, 2.0020, 1.9517, 1.8964, 1.8511, 1.8008, 1.7505, <<28>> , 0.24157, 0.19269, 0.14097, 0.090671, 0.040371, 0.000132}, {<<1>>}} cannot be transposed.

?

Any ideas on how to simply plot centroidEnergy vs. distanceInAir would be greatly appreciated! Thanks.
 
Physics news on Phys.org
  • #2
Well, this thread did not generate any responses after more than 12hrs, so perhaps it was misplaced. In an effort to get it out to a wider audience, I have moved it to college homework help. It has to do with a homework assignment anyway. Sorry for the inconvenience.

https://www.physicsforums.com/showthread.php?p=368279#post368279
 
  • #3
the arrays have different lengths,
distanceInAir has 41 elements, and centroidEnergy has 42 elements...
 

1. What is the purpose of plotting centroid energy and distance in air in Mathematica?

The purpose of plotting centroid energy and distance in air in Mathematica is to visualize the relationship between these two variables. This can help in understanding any patterns or trends in the data and can also aid in making predictions or drawing conclusions.

2. How do I plot centroid energy and distance in air in Mathematica?

To plot centroid energy and distance in air in Mathematica, you can use the built-in functions such as ListPlot or Plot. First, you will need to import the data into Mathematica and then use the appropriate function to plot the data points. You can also customize the plot by adding labels, legends, and changing the appearance of the plot.

3. What type of data is needed for plotting centroid energy and distance in air in Mathematica?

The data needed for plotting centroid energy and distance in air in Mathematica should include the values for both variables for each data point. The data can be in the form of a table, list, or array, as long as it is in a format that can be imported into Mathematica.

4. How can I interpret the plotted data for centroid energy and distance in air?

Interpreting the plotted data for centroid energy and distance in air will depend on the specific context and purpose of the plot. Generally, you can look for any patterns or trends in the data, such as a linear relationship or a correlation between the two variables. You can also calculate statistical measures, such as the slope or correlation coefficient, to further analyze the data.

5. Can I use Mathematica to plot centroid energy and distance in air for different data sets?

Yes, you can use Mathematica to plot centroid energy and distance in air for multiple data sets. You can either plot them on the same graph for comparison or create separate graphs for each data set. This can help in analyzing and comparing the relationships between centroid energy and distance in air for different scenarios or conditions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
14K
Back
Top