# Get modulus and plot complex function

I have the following function:

freq[a_, b_, t0_, tr_, s_] := -((b E^(-s (b + t0)) (b E^(s (b + t0)) (-1 +
b s) UnitStep[-b] - b E^(s t0) UnitStep[b] +
E^(s (b - tr)) (E^(s (t0 + tr)) (-1 + b s) UnitStep[-t0] +
E^(s tr) (-1 + b s - s t0) UnitStep[t0] -
E^(s (t0 + tr)) (-1 + b s) UnitStep[-t0 - tr] + (1 +
s (-b + t0 + tr)) UnitStep[t0 + tr])))/(s^2 tr))


Now I want to plot the function as follows:

Plot[ComplexExpand@Abs@ExpToTrig@freq[0, 1, 0, 10^-6, Iw], {w,0,10^9}]


However that doesn't work. I couldn't exact the absolute value of the complex function to plot it.
(w is a real positive number)

Does anyone know how to plot that?

• Iw should have a space in between, or use I*w Jul 9, 2020 at 19:44
• @flinty thanks! It took me one hour trying different methods. Jul 9, 2020 at 19:55

As mentioned by flinty, Iw should be I*w; and LogLinearPlot makes it easier to visualize.

freq[a_, b_, t0_, tr_,
s_] := -((b E^(-s (b + t0)) (b E^(s (b + t0)) (-1 + b s) UnitStep[-b] -
b E^(s t0) UnitStep[b] +
E^(s (b - tr)) (E^(s (t0 + tr)) (-1 + b s) UnitStep[-t0] +
E^(s tr) (-1 + b s - s t0) UnitStep[t0] -
E^(s (t0 + tr)) (-1 + b s) UnitStep[-t0 - tr] + (1 +
s (-b + t0 + tr)) UnitStep[t0 + tr])))/(s^2 tr))

LogLinearPlot[Evaluate[Abs@ExpToTrig@freq[0, 1, 0, 10^-6, I*w]], {w, 0, 10^9}]


• That's a good idea! Jul 9, 2020 at 19:58