I need help coding and running some functions for the signal in the attached. I need to find the value of the signal bandwidth using the following bandwidth definitions:
(a) Half-power bandwidth.
(b) Null-to-null bandwidth.
(c) 99% of power bandwidth. (Hint: Use numerical methods.)
(d) Bandwidth beyond which the attenuation is 35 dB.
Below is what I have so far for the code but I get several errors when I try to run. Could you please help.
Gx(f)=10^-4*(sin(pi*(f-10^6)*10^-4)/(pi*(f-10^6)*10^-4))
function Bw = half_power_bw(f, Gf)
i_half_lower = find(abs(Gf) < abs(Gf(imax))/sqrt(2), 1, 'first');
i_half_upper = find(abs(Gf) < abs(Gf(imax))/sqrt(2), 1, 'last');
Bw = f(i_half_upper) - f(i_half_lower);
function Bw = null_to_null_bw(f, Gf)
nulls = find(abs(Gf) == 0);
i_null_upper = nulls(end);
Bw = f(i_null_upper) - f(i_null_lower);
function Bw = power_bw(f, Gf, power_fraction)
total_power = trapz(f, abs(Gf).^2);
power_integral = cumtrapz(f, abs(Gf).^2);
i_power = find(power_integral >= total_power*power_fraction, 1, 'first');
function Bw = attenuation_bw(f, Gf, attenuation_dB)
attenuation_linear = 10^(-attenuation_dB/20);
i_attenuation = find(abs(Gf) < abs(max(Gf))*attenuation_linear, 1, 'first');