# How to plot a single plot with two variables

guys.

Suppose I have this equation:

M(t) = Meq + (M0 - Meq) exp[-t/τ]

where t denotes de time, Meq and M0 defined parameters and τ is an another defined parameter.

I can easily plot this equation (as a function of time) defining fixed values for Meq, M0 and τ, and this results in the plot shown below: But my real problem is: I need to plot the same equation (also as a funtion of time), but not for only one fixed value of τ, but actually to a distribution (a Log-Normal Distribution) of values of τ.

The result should be a plot with the same 'behaviour' of the plot for fixed values of τ. It should be something this way: If someone could help me, I would appreciate very much.

• What are the values for Meq and M0?
– zhk
Mar 14 '19 at 14:42

If I understand correctly, you want to check the magnetization plots for different distributions of $$\tau$$.

This would involve first generating the distribution function that obtains a certain distribution for $$\tau$$, let's start with the NormalDistribution.

dist[x_] := PDF[NormalDistribution[1, 0.4], Log@x];
taulist = Table[dist[x], {x, -6, 60, 4}][[3 ;;]];
Dimensions@taulist
N@taulist

(* Output

{15}

{0.743123, 0.140625, 0.00496708, 0.00022532, 0.0000140927,
1.16059*10^-6, 1.1985*10^-7, 1.49193*10^-8, 2.17127*10^-9,
3.60749*10^-10, 6.71557*10^-11, 1.37989*10^-11, 3.0918*10^-12,
7.47922*10^-13, 1.93718*10^-13}

*)


Or a LogNormalDistribution which you are actually interested in such as:

distlognorm[x_] := PDF[LogNormalDistribution[-1, 0.005], Log@x];
taulistlognorm =
Table[distlognorm[x], {x, 1.43, 1.46, 0.0020}][[2 ;;]];
Dimensions@taulistlognorm
N@taulistlognorm

(* Output

{15}

{0.0017637, 0.0558546, 0.955951, 8.92674, 45.9087, 131.231, 210.398, \
190.881, 98.8533, 29.4746, 5.1026, 0.517151, 0.0309356, 0.00110101, \
0.0000234976}

*)


Now we can use these values to define $$\tau$$ and the main function that you have suggested in the question.

Since you don't specify, I chose $$M_{eq} = 1$$ and $$M0 = -1$$, but you can of course change these.


Mt[t_, \[Tau]_] := Module[{Meq = 1, M0 = -1},
Return[Meq + (M0 - Meq) Exp[-t/\[Tau]]];
];



Using this function Mt[x], we can plot the two distributions and check it's dependence on the variation with $$\tau$$. Code for the plots is given below:

Module[{},
pltlist = {};
Do[
AppendTo[pltlist,
LogLinearPlot[{Mt[t, taulist[[ntau]]]}, {t, Exp[-100], Exp},
PlotStyle -> ColorData[ntau, "ColorList"]]]
, {ntau, 1, 15}];
pltnorm = Show[pltlist, Frame -> True, FrameLabel -> {"t,(sec)", ""},
FrameStyle -> Directive[Black, FontSize -> 16]]
]

Module[{},
pltlist = {};
Do[
AppendTo[pltlist,
LogLinearPlot[{Mt[t, taulistlognorm[[ntau]]]}, {t, Exp[-100], Exp},
PlotStyle -> ColorData[ntau, "ColorList"]]]
, {ntau, 1, 15}];
pltlognorm = Show[pltlist, Frame -> True, FrameLabel -> {"t,(sec)", ""},
FrameStyle -> Directive[Black, FontSize -> 16]]
]


I have an idea for your plot

Meq = 0.5;
M0 = 1;
Plot[Evaluate[{Meq + (M0 - Meq)/E^(t/tau)} /. tau -> {2, 4, 6}], {t, -10, 4}, PlotRange -> All] Thereby you can specify different values for tau and plot them together. By the way the function you are sharing with us is an exponential decay function, and not a sigmoidal or logistic function. I hope the pictures you shared are only examples and you don't expect a sigmoidal result?!

A sigmoidal function would look like:

1/(1+e^-t)

I don't understand what you want to do with the LogNormalDistribution.

• Hi, Jacccy! Thanks for your feedback. Sorry, I think I was not clear enough when explaining my question. The equation that I have posted here describe the evolution of a magnetization of a ensembele of magnetic minerals with time. If we were dealing with an ensemble with only one kind of mineral (same volume and shape), then we'll have just one value of τ. This is the case of the first plot. But in the second plot (I had took this pic from a paper), the author discuss the general case of an ensemble with different minerals, different volumes and shapes, which leads to a set of values of τ. Mar 14 '19 at 16:52
• The author of the paper then discuss three different cases, between then the case where the values of τ are distributed in a log-normal distribution. Mar 14 '19 at 16:53
• The conclusion that I hope reach is the same of the author, that is, even with the parameter τ varying according to a given distribution, the behaviour of the magnetization with time should almost the same as the case of a single value of τ. Mar 14 '19 at 16:55