0
$\begingroup$

Need to find max and min values like on pic. I am wondering how I could determine max and min values of oscillations ? How could I find these values: enter image description here My code:

<< PhysicalConstants`
<< Units`

Subscript[I, critical] = 10 *10^-3(*Milli Ampere*);
c = 1.2*10^-13 (*Farad*);
Subscript[R, N] = 50*10^-3 (*Milli Ohm*);
η = 1.2; 
h = PlanckConstantReduced*1/(Joule Second);
e = ElectronCharge*1/Coulomb;
Subscript[t, 0] = 0;
Subscript[t, 1] = 1*10^-11;

Subscript[ω, c] = η*((2 e)/h)*Subscript[I, critical]*Subscript[R, N];
β = 2 e/h*Subscript[I, critical]*c*(Subscript[R, N])^2;
Subscript[I, dc] = Subscript[I, critical]*1.5;
b = Subscript[I, dc]/Subscript[I, critical];

eq = NDSolve[{N[β/Subscript[ω, c]^2]*φ''[t] + 
N[1/Subscript[ω, c]]*φ'[t] + Sin[φ[t]] - b == 0, 
φ'[0] == 0, φ[0] == Pi/2}, φ, {t, Subscript[t, 0],  Subscript[t, 1]}]; 

Plot[N[h/(2 e)*Evaluate[φ'[t] /. eq][[1]]], {t, Subscript[t, 0], 
Subscript[t, 1]}, PlotStyle -> Orange, PlotLegends -> {"V(t)"}, 
AxesLabel -> {"t,s", "V(t)"}]
$\endgroup$
  • $\begingroup$ What version are you using? Those two packages you loaded aren't needed anymore in the current version. Also: you could use WhenEvent[] so that the extrema are returned while you are solving your differential equation. $\endgroup$ – J. M. is in limbo Apr 13 '18 at 2:11
3
$\begingroup$

The following extracts all Line objects from the plot, and selects all y-coordinates form the first (and only) from these objects. In the end, we simply apply MinMax.

plot = Plot[
   N[h/(2 e)*Evaluate[φ'[t] /. eq][[1]]], {t, 
    Subscript[t, 0], Subscript[t, 1]}, PlotStyle -> Orange, 
   PlotLegends -> {"V(t)"}, AxesLabel -> {"t,s", "V(t)"}];

MinMax[Cases[plot, _Line, All][[1, 1, All, 2]]]

{1.22445*10^-8, 0.00149979}

Starting the list a bit later (because the beginning seems to contain bad data) yields

MinMax[Cases[plot, _Line, All][[1, 1, 10 ;;, 2]]]

{0.000298883, 0.00149979}

Alternatively, you may use Maximize and Minimize directly on the function that you have plotted:

epsilon = 10^-12;
Maximize[{N[h/(2 e)*Evaluate[φ'[t] /. eq][[1]]], 
  Subscript[t, 0] <= t <= Subscript[t, 1]}, t]
Minimize[{N[h/(2 e)*Evaluate[φ'[t] /. eq][[1]]], 
  Subscript[t, 0] + epsilon <= t <= Subscript[t, 1]}, t]

{0.00149984, {t -> 1.55926*10^-12}}

{0.000300006, {t -> 3.09243*10^-12}}

$\endgroup$
  • $\begingroup$ PeakDetect[] can also be used on the raw data produced by Plot[]. $\endgroup$ – J. M. is in limbo Apr 13 '18 at 2:09

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.