enter image description here

I have three sets of data. I would like to plot them in the same graph. Then plot the following fittings to the data. Any help is appreciated!

  • f(v) = (v^2)*exp(-mv^2/2 kb T)
  • f(v) = (v^3)*exp(-mv^2/2 kb T)


data = Import[
   "/Users/julissavelasquez/Box/1_Harrison Lab/03_Formic \

hyperthermal = 
  Import["/Users/julissavelasquez/Box/1_Harrison Lab/03_Formic \

Plot[data, {x, 0, 2}]

Hyperthermal data:

Data for copying/pasting is in the Google Sheet: https://docs.google.com/spreadsheets/d/1Z-tVwtRmt6UD3v67eMO0e5lws8wwZ6G3hLaZJkETSK0/edit?usp=sharing

  • 1
    $\begingroup$ Welcome to the Mathematica Stack Exchange. Could you please include your data in a copy-paste-able form? Also include any Mathematica code that you have tried out so far as this is a stack site about the technical computing software called Mathematica and the associated Wolfram Language. $\endgroup$
    – Syed
    Commented Feb 28, 2022 at 13:46
  • $\begingroup$ @Syed I believe my data was too much to add in as code. I included a Google Sheets link with the data there. $\endgroup$ Commented Feb 28, 2022 at 14:12
  • $\begingroup$ Right now, the provided link is asking me to log into my google account. Please make it an accessible 1-click download. $\endgroup$
    – Syed
    Commented Feb 28, 2022 at 14:22
  • $\begingroup$ @Syed Sorry about that. Please try again. $\endgroup$ Commented Feb 28, 2022 at 14:24
  • $\begingroup$ The energy in your data is the same everywhere. Then explain better what you want to fit and wich column you want to plot against which column. $\endgroup$ Commented Feb 28, 2022 at 14:48

2 Answers 2

data = First[Import["~/Downloads/Data.xlsx", "SkipLines" -> 2]][[1 ;; -2]];

total = data[[All, 1 ;; 2]]
hyper = data[[All, 3 ;; 4]]
thermal = data[[All, 5 ;; 6]]

ListLinePlot[{total, hyper, thermal},
 PlotLabels -> {"Total", "Hyper", "Thermal"},
 PlotTheme -> "Detailed",
 ImageSize -> 600]

enter image description here

The fit is not good the model probably needs adjusting or I have misinterpreted it.

totalFit = NonlinearModelFit[total, (v^2)*Exp[-m v^2/(2 k bt)], {m, k, bt}, v]

Show[ListPlot[total], Plot[totalFit[x], {x, 0, 1.2}], Frame -> True]

data = Import["/Users/roberthanlon/Downloads/Data.xlsx", 
    "SkipLines" -> 2][[1]];

Eliminate any missing data

total = data[[All, 1 ;; 2]] /. {"", ""} :> Nothing;

In your model, m/2 kb T acts as a single constant. The split of any derived value into these separate factors is arbitrary. You also need an overall scale factor. Use the model a*(v^n)*Exp[-c v^2] with n being either 2 or 3.

(totalFit2 = 
   NonlinearModelFit[total, a*(v^2)*Exp[-c v^2], {a, c}, v]) // Normal

(* 11.1953 E^(-4.6119 v^2) v^2 *)

(totalFit3 = 
   NonlinearModelFit[total, a*(v^3)*Exp[-c v^2], {a, c}, v]) // Normal

(* 37.2111 E^(-6.30875 v^2) v^3 *)

  ListLinePlot[total, PlotStyle -> ColorData[97][3]],
  Plot[{totalFit2[x], totalFit3[x]}, {x, 0, 1.2}],
  Frame -> True],
  LineLegend[ColorData[97] /@ Range[3], {v^2, v^3, "data"}],
  {0.8, 0.7}]]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.