Wikibodeplots.m
From Course Wiki
function wikibodeplots % Customize plots bodeOptions = bodeoptions; bodeOptions.FreqUnits = 'Hz'; bodeOptions.Title.FontSize = 11; bodeOptions.Title.FontWeight = 'Bold'; bodeOptions.XLabel.FontSize = 10; bodeOptions.XLabel.FontWeight = 'Bold'; bodeOptions.YLabel.FontSize = 10; bodeOptions.YLabel.FontWeight = 'Bold'; % Setup transfer functions fCutOff = 1; omegaCutOff = 2*pi*fCutOff; % omega = 2 pi f fLowPass = 10; omegaLowPass = 2*pi*fLowPass; fHighPass = 0.1; omegaHighPass = 2*pi*fHighPass; hFirstOrder = tf (1, [1/omegaCutOff 1]); hSecondOrder = tf (1, [1/omegaCutOff^2 2/omegaCutOff 1]); hHighPass = tf ([1/omegaCutOff 0], [1/omegaCutOff 1]); hBandPass = tf ([1/omegaHighPass 0], ... [1/(omegaLowPass*omegaHighPass) 1/omegaLowPass+1/omegaHighPass 1]); % Bode plot of low pass figure(1) bodeOptions.Title.String = '1st-order Low Pass Filter'; bodeplot(hFirstOrder, bodeOptions); % Bode plot of high pass figure(2) bodeOptions.Title.String = '1st-order High Pass Filter'; bodeplot(hHighPass, bodeOptions); % Bode plot of 2nd-order low pass figure(3) bodeOptions.Title.String = '2nd-order Low Pass Filter'; bodeplot(hSecondOrder, bodeOptions); % Bode plot of band pass figure(4) bodeOptions.Title.String = 'Band Pass Filter'; bodeplot(hBandPass, bodeOptions); end