1
$\begingroup$

I have next code

m[t_] := {mx[t], my[t], mz[t]}

γ = 28;
h = 6.62*10^-34;
e = 1.6*10^-19;

Subscript[μ, 0] = 1.25*10^-6;
Subscript[μM, 0] = 800*10^-3;
Subscript[M, 0] = 0.64*10^6;
Subscript[r, 0] = 100*10^-9;
Subscript[l, 0] = 3*10^-9;
Subscript[I, dc] = 1*10^-3;
Subscript[B, dc] = 200*10^-3;
Subscript[α, G] = 0.01;

p = {0, 0, 1};
σ =(γ*h/2*e)*1/(Subscript[M, 0]*Pi*(Subscript[r, 0])^2)*Subscript[l, 0];
Subscript[B, eff] = {Subscript[B, dc], 0, 0}-Subscript[μM, 0]*(m[t]*p);

system1 ={D[m[t], t] ==γ*(Cross[Subscript[B, eff], m[t]]) + Subscript[α, 
G]*(Cross[m[t], D[m[t], t]]) +σ*Subscript[I, dc]*(Cross[m[t], Cross[m[t], 
p]]),(m[t] /. t -> 0) == {0, 1, 0}};

s1 = NDSolve[system1, m[t], {t, 0, 50}]

Plot[Evaluate[{mx[t], my[t], mz[t]} /. s1], {t, 0, 50},AxesLabel -> {t, m}]

Than i plot graph mx[t], {t,0,5}

Plot[Evaluate[mx[t] /. s1], {t, 0, 5}, AxesLabel -> {t, mx}]

than i find all minima and maxima on graph higher

z = Reap[s1 = 
    NDSolve[{system1, WhenEvent[mx'[t] == 0, Sow[t]]}, 
     m[t], {t, 0, 5}]][[2, 1]]

I need to plot two graphs together this

Plot[Evaluate[mx[t] /. s1], {t, 0, 5}, AxesLabel -> {t, mx}]

and the graph of these results

z = Reap[s1 = 
        NDSolve[{system1, WhenEvent[mx'[t] == 0, Sow[t]]}, 
         m[t], {t, 0, 5}]][[2, 1]]
$\endgroup$

closed as off-topic by C. E., ilian, happy fish, m_goldberg, Feyre Oct 11 '16 at 16:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – C. E., ilian, happy fish, m_goldberg, Feyre
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Take a look at Show : reference.wolfram.com/language/ref/Show.html $\endgroup$ – Julien Kluge Oct 10 '16 at 18:34
  • $\begingroup$ Also, try to make your examples a Minimum Working Example, to highlight just the crux of your problem. It makes it easier for people to see where / how to help you, and often highlights new approaches to you in contracting the problem! $\endgroup$ – Quantum_Oli Oct 10 '16 at 20:00
3
$\begingroup$

I guess you want to indicate on the plot the local maxima and minima which locations are stored in z. With

plot = Plot[Evaluate[mx[t] /. s1], {t, 0, 5}, AxesLabel -> {t, mx}];

let's define for simplicity

f[t_] := Evaluate@First[mx[t] /. s1]

find the points

loc = {#, f[#]} & /@ z;

plot2 = ListPlot[loc, PlotStyle -> {Red, PointSize[Medium]}];

and Show the two plots:

Show[plot, plot2]

enter image description here


Instead defining f[t] and loc, you can get the {x,y} points by a slight change in Sow in z:

z = Reap[s1 = 
    NDSolve[{system1, WhenEvent[mx'[t] == 0, Sow[{t, mx[t]}]]}, 
     m[t], {t, 0, 5}]][[2, 1]]

Then directly

plot2 = ListPlot[z, PlotStyle -> {Red, PointSize[Medium]}]

and

Show[plot, plot2]

gives the same output.

$\endgroup$

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