Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DiscreteHankelTransform[f1_, p_, Np_, rmax_] :=
- Module[{a, aNp1, rv, uv, res, umax, T , J, F1, F2},
- a = Table[N[BesselJZero[p, n]], {n, 1, Np}];
- aNp1 = BesselJZero[p, Np + 1];
- umax = aNp1/(2 Pi rmax);
- rv = a/(2 Pi umax);
- uv = a/(2 Pi rmax);
- J = Abs[BesselJ[p + 1, a]];
- T = BesselJ[p, TensorProduct[a, a]/(2 Pi rmax umax)]/(
- TensorProduct[J, J] Pi rmax umax) ;
- F1 = (If[MatchQ[Head[f1], List], f1, f1[rv]] rmax)/J;
- F2 = T.F1;
- Return[Transpose[{uv, J/umax F2}]];
- ];
- InverseDiscreteHankelTransform[f2_, p_, Np_, umax_] :=
- Module[{a, aNp1, rv, uv, res, rmax, T , J, F1, F2},
- a = Table[N[BesselJZero[p, n]], {n, 1, Np}];
- aNp1 = BesselJZero[p, Np + 1];
- rmax = aNp1/(2 Pi umax);
- rv = a/(2 Pi umax);
- uv = a/(2 Pi rmax);
- J = Abs[BesselJ[p + 1, a]];
- T = BesselJ[p, TensorProduct[a, a]/(2 Pi rmax umax)]/(
- TensorProduct[J, J] Pi rmax umax) ;
- F2 = (If[MatchQ[Head[f2], List], f2, f2[uv]] umax)/J;
- F1 = T.F2;
- Return[Transpose[{rv, J/rmax F1}]];
- ];
- f = Sin[2 Pi g #]/(2 Pi g #) &;
- F0[u_, p_, g_] =
- Piecewise[{
- {HankelTransform[f, u, p, {p >= 0, 0 < u < g}], 0 <= u < g},
- {Sin[p ArcSin[g/u]]/(2 Pi g Sqrt[u^2 - g^2]), u > g},
- {Infinity, u == g}
- }, Null]
- SetAttributes[F0, Listable];
- dF01 = DiscreteHankelTransform[f /. g -> 5, 1, 256, 3.0];
- dF04 = DiscreteHankelTransform[f /. g -> 5, 4, 256, 3.0];
- dF01max = Max[Abs[dF01]];
- dF04max = Max[Abs[dF04]];
- dynerr1 = Transpose[{dF01[[;; , 1]], 20 Log10[Abs[F0[#[[1]], 1, 5] - #[[2]]]/dF01max] & /@dF01}];
- dynerr4 = Transpose[{dF04[[;; , 1]], 20 Log10[Abs[F0[#[[1]], 4, 5] - #[[2]]]/dF04max] & /@dF04}];
- GraphicsGrid[{
- {Show[
- Plot[F0[u, 1, 5], {u, 0, 20},
- PlotRange -> {-0.005, 0.05},
- Exclusions -> None,
- Frame -> True,
- Axes -> False,
- FrameLabel -> {"u", "!(*SubscriptBox[(f), (2)])[[Nu]]"},
- PlotLabel -> "HT, p[Equal]1"],
- ListPlot[dF01]],
- ListLinePlot[dynerr1,
- Frame -> True,
- Axes -> False,
- FrameLabel -> {"[Nu]", "dB"},
- PlotLabel -> "e([Nu]), p[Equal]1",
- PlotRange -> {{0, 20}, {-180, 0}}]},
- {Show[
- Plot[F0[u, 4, 5], {u, 0, 20},
- PlotRange -> {-0.03, 0.03},
- Exclusions -> None,
- Frame -> True,
- Axes -> False,
- FrameLabel -> {"[Nu]", "!(*SubscriptBox[(f), (2)])[[Nu]]"},
- PlotLabel -> "HT, p[Equal]4"], ListPlot[dF04]],
- ListLinePlot[dynerr4,
- Frame -> True,
- Axes -> False,
- FrameLabel -> {"[Nu]", "dB"},
- PlotLabel -> "e([Nu]), p[Equal]4",
- PlotRange -> {{0, 20}, {-180, 0}}]}},
- ImageSize -> Large]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement