Bandwidth function in MATLAB

Status
Not open for further replies.

chart2006

Newbie level 2
Joined
Jul 12, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
I'm pretty sure I'm screwing this up pretty badly due to my limited understanding of MATLAB but I am trying my best. A passive low pass filter was assembled and measured the output via an o-scope. At each frequency from the signal generator we wrote down the input/ouput Vpp. Using that data I am trying to determine an ideal bandwidth however I am getting an error I simply cannot identify, "Undefined function 'bandwidth' for input arguments of type 'double'." Here is the m-file code. If I am simply going about this all wrong can someone identify the correct method? Thank you.

clear all
clc
close all

f = [1e3 5e3 10e3 13.2e3 15e3 20e3 25e3 30e3 35e3 40e3 45e3 50e3 55e3 ...
60e3 65e3 70e3]; % Frequency, Hz
fc = 13.2e3; % Cutoff Frequency

Vin = [200e-3 200e-3 200e-3 200e-3 200e-3 200e-3 200e-3 200e-3 200e-3 ...
200e-3 200e-3 200e-3 200e-3 200e-3 200e-3 200e-3]; % Input, mVpp

Vout = [0.168e-1 0.656e-1 1.12e-1 1.32e-1 1.44e-1 1.60e-1 1.68e-1 ...
1.76e-1 1.76e-1 1.80e-1 1.84e-1 1.84e-1 1.88e-1 1.91e-1 1.92e-1 ...
1.92e-1]; % Output, mVpp

DC_gain = Vout./Vin; % DC gain.
dB_gain = 20*log10(Vout./Vin) % Gain.
dB_drop = max(dB_gain-3) % Critical gain drop(Cutoff point for the -3 dB bandwidth/(range of
% frequencies where the amplitude gain is above 70.7% of the maximum
% amplitude gain, and above half the maximum power gain)).

semilogx(f, dB_gain, 'sk-')
grid;
xlabel('Frequency, Hz');
ylabel('Gain, dB')
title('Gain vs. Frequency');

fb = bandwidth(f, dB_drop) % Calculates the bandwidth.
bw = 100*(fb/fc) % Bandwidth percentage.
 

fb = bandwidth(f, dB_drop) <---------- What is it?
 


this is how it looks with me
 

Attachments

  • Bandwith with freqeuncy.png
    161.1 KB · Views: 64

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…