I would like to put random values like s = 0.1, 0.7, 0.4, 0.15, and 0.18 to get the output results which are ( X and Rn ) for these values in different Excel files or in the same Excel file, instead of putting them manually for each single code. How can I do that? Because i will have a lot of s values so basically the only that changes is s which gives different solutions in each case, Kindly help if you can
ClearAll["Global"]
ClearAll[My`Print]
ClearAll[X1]
SetAttributes[My`Print, HoldAll]
My`Print[args___] :=
Do[Print[Extract[Hold[args], i, HoldForm], "=", {args}[[i]]], {i,
Length[{args}]}]
s = 0.15; c = 2; k = (1/2)*(1 - a^2)*s^2; h = 10; n = 0.1; a =
n/(1 - n);
p = -((Sqrt[(a*(1 - c)*y - 1)^2 - 2*(1 - 2*c)*(-(a*y) - k + y^2/2)] +
a*(1 - c)*y - 1)/(1 - 2*c));
f := (-(c*p + 1)^(-(1/c)))*(c*y + 1)^((1 - c)/c); NIntegrate[f, {y,
s, -s}];
\[Rho] = h/
NIntegrate[
f, {y, s, -s}]; rn = \[Rho]*(c*s + 1)^(1/c); rp = \[Rho]*(1 -
c*s)^(1/c);
\[Delta] = rp - rn; My`Print[\[Rho], rn, rp, \[Delta]]
g =
-(1 - (c*(Sqrt[((a*(1 - c)*((y/\[Rho])^c - 1))/c - 1)^2 -
2*(1 - 2*c)*(-((a*((y/\[Rho])^c - 1))/c) +
(1/2)*(((y/\[Rho])^c - 1)/c)^2 -
k)] + (a*(1 - c)*((y/\[Rho])^c - 1))/c - 1))/(1 -
2*c))^(-c^(-1));
R = 20; X = ({#1,
NIntegrate[g, {y, rn, (#1*\[Delta])/R + rn}] - h/2} & ) /@
Range[R];
Rn = ({#1, (#1*\[Delta])/R + rn} & ) /@ Range[R];
XvsRn = Transpose[{Last /@ X, Last /@ Rn}]
ListLinePlot[(Callout[#1, Round[#1, 0.001] -> Point] & ) /@ XvsRn,
Mesh -> All,
MeshStyle -> Directive[PointSize[Medium], Red],
FrameLabel -> (Style[#1, Black, 14] & ) /@ {"X", "Rn"},
ImageSize -> 600,
PlotTheme -> "Detailed"]
(Export["mfile1.xlsx", #1] & )[Prepend[{"X", "Rn"}][XvsRn]]