1
$\begingroup$

I want to plot an amplitude vs frequency with this formula: enter image description here

By using this data:

enter image description here

So it should look like this:

enter image description here

Unfortunately, I don´t manage it to plot this. Could someone help please ?

$\endgroup$
  • $\begingroup$ Could you please make the input data a $ 9\times 2 $ list? $\endgroup$ – Αλέξανδρος Ζεγγ Jul 31 at 6:49
  • 1
    $\begingroup$ xx = {4.19, 3.93, 3.7, 3.49, 3.31, 3.31, 3.14, 2.99, 1.75}; yy = {0.18, 0.35, 0.45, 1.06, 1.13, 0.77, 0.57, 0.34, 0.14}; $\endgroup$ – Tom Jul 31 at 7:06
  • $\begingroup$ Thi forum is devoted to WolframMathematica (shorter Mathematica). There is no need to stress Mathematica in the title. $\endgroup$ – user64494 Jul 31 at 7:23
  • $\begingroup$ The size of your data which equals 9 is too small for reliable conclusions. $\endgroup$ – user64494 Jul 31 at 7:26
3
$\begingroup$

This is only meant as an answer to a question in one of the comments about how to reverse the x-axis that I couldn't fit into a comment easily.

You can add the option ScalingFunctions -> {"Reverse", None} to the plot in order to reverse the x-axis. Unfortunately, this means that the data points themselves will not show up. Probably the easiest solution is to show the points in a separate ListPlot and reverse the x-axis there as well:

Show[
 Plot[
  Evaluate[model /. fittedparameters],
  {\[Omega], 1, 5},
  PlotRange -> All,
  PlotStyle -> Blue,
  ScalingFunctions -> {"Reverse", None}
  ],
 ListPlot[
  data,
  PlotStyle -> Red,
  ScalingFunctions -> {"Reverse", None}
  ]
 ]

Fitted model with reversed x-axis.

$\endgroup$
  • $\begingroup$ Looks great, thank you! $\endgroup$ – Tom Jul 31 at 15:18
  • $\begingroup$ No problem, but you can only accept one of the answers, and I think it should go to Αλέξανδρος-Ζεγγ as they answered the main question. My "answer" was just meant to slightly build upon their answer. $\endgroup$ – MassDefect Jul 31 at 16:06
  • $\begingroup$ So it cannot work with Epilog? $\endgroup$ – Αλέξανδρος Ζεγγ Aug 1 at 5:17
  • 1
    $\begingroup$ @ΑλέξανδροςΖεγγ IMO, the way MMA reverses the axes is a bit hack-y. It basically takes the negative of everything so that Epilog points are no longer in the place you would expect them. To reverse the x-axis using your method, I would add ScalingFunctions -> {"Reverse", None} to the list of options, and then inside the Epilog I would change Point[data] to Point[data.{{-1, 0}, {0, 1}}]. $\endgroup$ – MassDefect Aug 1 at 5:54
  • 1
    $\begingroup$ @MassDefect Inspiring, thx very much! $\endgroup$ – Αλέξανδρος Ζεγγ Aug 1 at 6:02
4
$\begingroup$

The input data is arranged as

data = {{4.19, 3.93, 3.7, 3.49, 3.31, 3.31, 3.14, 2.99, 1.75}, {0.18, 0.35, 0.45, 1.06, 1.13, 0.77, 0.57, 0.34, 0.14}}\[Transpose];

Then fit a nonlinear model

model = (a ω^2) / Sqrt[(ω^2 - ωe^2)^2 + 4 γ^2 ωe^2];
fittedparameters = FindFit[data, model, {a, ωe, γ}, ω]

which returns

{a -> 0.0895665, ωe -> 3.394, γ -> 0.123515}

So finally plot the result

Plot[Evaluate[model /. fittedparameters], {ω, 1, 5}, PlotRange -> All, PlotStyle -> Blue, Epilog -> {Red, PointSize[.015], Point[data]}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you very much, looks great!!! $\endgroup$ – Tom Jul 31 at 7:19
  • $\begingroup$ I think the plot should converge towards 0, not starting at 0. How could we mirror the x-axis ? $\endgroup$ – Tom Jul 31 at 7:59
  • $\begingroup$ @Tom Could please rephrase your statement, but I could really not quite catch you. $\endgroup$ – Αλέξανδρος Ζεγγ Jul 31 at 8:01
  • $\begingroup$ I mean, how could we realize to start x-axis at 5 going down to 0 from left to right, so the graph would decay towards 0.. so just rotate x-axis 180° $\endgroup$ – Tom Jul 31 at 8:06
  • $\begingroup$ @Tom Do you mean to make the ticks on the $ x $-axis go from large to small? $\endgroup$ – Αλέξανδρος Ζεγγ Jul 31 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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