I'm currently trying to vizualize the relation between time and frequency domain and their behavior for a single rectangular pulse regarding different paramters. A special focus is set on the real Re and imaginary Im part of the frequency spectrum of a shifted pulse.
I wrote a Mathematica script that plots the pulse in time domain, the pulse's fourier transform in shape of the real and the imaginary part, and the absolute value of the real part as well. Further it manipulates the parameters duty cycle d, amplitude a, DC bias b, and time shift s.
Actually, the vizualization of the pulse in time domain works fine and as long as I do not implement the time shift for the Fourier transform the spectra are calculated correctly! However, the Fourier is burning my time and nerves since I tried to implement that functionality. I am pretty new in the fields of Mathematica, so there might be fundamental mistakes in thinking or coding which you will hopefully tell me ... ;o)
Here is my current script which is working so far, but the time shift is not implemented for Fourier:
Manipulate[
Grid[{
{
Plot[a * UnitBox[(t - s)/d] + b, {t, -2.1, 2.1}, PlotLabel -> "Pulse",
Exclusions -> None, Filling -> Axis, PlotRange -> 1.0,
PerformanceGoal -> "Speed", ImageSize -> Medium],
Plot[Abs[FourierTransform[a * UnitBox[t/d] + b, t, f,
FourierParameters -> {1, -1}]], {f, -25, 25}, PlotLabel ->
"Absolute Real Part", Exclusions -> None, Filling -> Axis, PlotRange
-> 1.0, PerformanceGoal -> "Speed", ImageSize -> Medium]
},
{
Plot[Re[FourierTransform[a * UnitBox[t/d] + b, t, f, FourierParameters
-> {1, -1}]], {f, -25, 25}, PlotLabel -> "Real Part", Exclusions ->
None, Filling -> Axis, PlotRange -> 1.0, PerformanceGoal -> "Speed",
ImageSize -> Medium],
Plot[Im[FourierTransform[a * UnitBox[t/d] + b, t, f, FourierParameters
-> {1, -1}]], {f, -25, 25}, PlotLabel -> "Imaginary Part",
Exclusions -> None, Filling -> Axis, PlotRange -> 1.0,
PerformanceGoal -> "Speed", ImageSize -> Medium]
}
}],
Style["Pulse-Width Signal", 12, Bold], {{d, 0.5, "Duty Cycle"}, 0.001,
1.0, 0.001}, {{s, 0, "Time Shift"}, -2.0, 2.0, 0.1}, {{a, 1.0,
"Amplitude"}, -2.0, 2.0, 0.1}, {{b, 0.0, "DC Bias"}, -1.0, 1.0, 0.1},
ControlPlacement -> Left
]
Currently, the time-to-frequency transformation works for a rectangular pulse of certain period, duty cycle, amplitude, and DC bias. Only the time shift s impedes the vizualization of the relations between pulse in time and spectrum in frequency. Including the calculation with time shift s leads to abortion or endless processing.
To increase clearity and efficiency I tried to centralize the calculations of the rectangular pulse function and its Fourier transform, but the definitions usually did not work and I do not know why!
Rectangular pulse function with time shift:
a * UnitBox[(t - s)/d] + b
Tried definition:
myPWM[t_, duty_, ampl_, bias_, shift_] :=
ampl * (UnitBox[(t - shift)/duty]) + bias;
myPWMF[t_, duty_, ampl_, bias_, shift_] :=
FourierTransform[myPWM[t, duty, ampl, bias, shift], t, f];
Is it the wrong way to define such functions? Including myPWM and myPWMF leads to abortion, endless processing and empty diagrams.
I hope you can help me to finish this nice vizualization! Thank you very much in advance!
(t-s)/d
instead oft/d
) works but It takes 40 secondes to update the image (my machine : I7). This is not normal. $\endgroup$Plot[...]
in aEvaluate[...]
. $\endgroup$