Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. DiscreteHankelTransform[f1_, p_, Np_, rmax_] :=
  2. Module[{a, aNp1, rv, uv, res, umax, T , J, F1, F2},
  3. a = Table[N[BesselJZero[p, n]], {n, 1, Np}];
  4. aNp1 = BesselJZero[p, Np + 1];
  5. umax = aNp1/(2 Pi rmax);
  6. rv = a/(2 Pi umax);
  7. uv = a/(2 Pi rmax);
  8. J = Abs[BesselJ[p + 1, a]];
  9. T = BesselJ[p, TensorProduct[a, a]/(2 Pi rmax umax)]/(
  10. TensorProduct[J, J] Pi rmax umax) ;
  11. F1 = (If[MatchQ[Head[f1], List], f1, f1[rv]] rmax)/J;
  12. F2 = T.F1;
  13. Return[Transpose[{uv, J/umax F2}]];
  14. ];
  15.  
  16. InverseDiscreteHankelTransform[f2_, p_, Np_, umax_] :=
  17. Module[{a, aNp1, rv, uv, res, rmax, T , J, F1, F2},
  18. a = Table[N[BesselJZero[p, n]], {n, 1, Np}];
  19. aNp1 = BesselJZero[p, Np + 1];
  20. rmax = aNp1/(2 Pi umax);
  21. rv = a/(2 Pi umax);
  22. uv = a/(2 Pi rmax);
  23. J = Abs[BesselJ[p + 1, a]];
  24. T = BesselJ[p, TensorProduct[a, a]/(2 Pi rmax umax)]/(
  25. TensorProduct[J, J] Pi rmax umax) ;
  26. F2 = (If[MatchQ[Head[f2], List], f2, f2[uv]] umax)/J;
  27. F1 = T.F2;
  28. Return[Transpose[{rv, J/rmax F1}]];
  29. ];
  30.  
  31. f = Sin[2 Pi g #]/(2 Pi g #) &;
  32. F0[u_, p_, g_] =
  33. Piecewise[{
  34. {HankelTransform[f, u, p, {p >= 0, 0 < u < g}], 0 <= u < g},
  35. {Sin[p ArcSin[g/u]]/(2 Pi g Sqrt[u^2 - g^2]), u > g},
  36. {Infinity, u == g}
  37. }, Null]
  38. SetAttributes[F0, Listable];
  39.  
  40. dF01 = DiscreteHankelTransform[f /. g -> 5, 1, 256, 3.0];
  41. dF04 = DiscreteHankelTransform[f /. g -> 5, 4, 256, 3.0];
  42. dF01max = Max[Abs[dF01]];
  43. dF04max = Max[Abs[dF04]];
  44. dynerr1 = Transpose[{dF01[[;; , 1]], 20 Log10[Abs[F0[#[[1]], 1, 5] - #[[2]]]/dF01max] & /@dF01}];
  45. dynerr4 = Transpose[{dF04[[;; , 1]], 20 Log10[Abs[F0[#[[1]], 4, 5] - #[[2]]]/dF04max] & /@dF04}];
  46. GraphicsGrid[{
  47. {Show[
  48. Plot[F0[u, 1, 5], {u, 0, 20},
  49. PlotRange -> {-0.005, 0.05},
  50. Exclusions -> None,
  51. Frame -> True,
  52. Axes -> False,
  53. FrameLabel -> {"u", "!(*SubscriptBox[(f), (2)])[[Nu]]"},
  54. PlotLabel -> "HT, p[Equal]1"],
  55. ListPlot[dF01]],
  56. ListLinePlot[dynerr1,
  57. Frame -> True,
  58. Axes -> False,
  59. FrameLabel -> {"[Nu]", "dB"},
  60. PlotLabel -> "e([Nu]), p[Equal]1",
  61. PlotRange -> {{0, 20}, {-180, 0}}]},
  62. {Show[
  63. Plot[F0[u, 4, 5], {u, 0, 20},
  64. PlotRange -> {-0.03, 0.03},
  65. Exclusions -> None,
  66. Frame -> True,
  67. Axes -> False,
  68. FrameLabel -> {"[Nu]", "!(*SubscriptBox[(f), (2)])[[Nu]]"},
  69. PlotLabel -> "HT, p[Equal]4"], ListPlot[dF04]],
  70. ListLinePlot[dynerr4,
  71. Frame -> True,
  72. Axes -> False,
  73. FrameLabel -> {"[Nu]", "dB"},
  74. PlotLabel -> "e([Nu]), p[Equal]4",
  75. PlotRange -> {{0, 20}, {-180, 0}}]}},
  76. ImageSize -> Large]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement