📄 bwcalc.m
字号:
function [bw,err] = bwcalc(db,omega,lfg_db)% Determines the bandwidth of a system, either open- or % closed-loop, by:% 1. evaluating the freq response for a number of frequencies% 2. finding the freq at which the magnitude is 3.0 db lower % than the LFG%Inputs: db - vector of magnitudes (decibels) % omega - vector of corresponding frequencies% lfg_db - low-frequency gain (dB)%Outputs: bw - bandwidth, same scale as omega% err - error flag% 1 -> mag at lowest freq was < lfg -3.0 (db)% 2 -> mag at all freq were > lfg -3.0%%%%%%%%%%%%%%%%%%% bwcalc.m %%%%%%%%%%%%%%%%%%%%% Discrete-Time Control Problems using %% MATLAB and the Control System Toolbox %% by J.H. Chow, D.K. Frederick, & N.W. Chbat %% Brooks/Cole Publishing Company %% September 2002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%err = 0;bw = []; % evaluate freq response% get index of the frequency just after the% magnitude goes 3 db below the LFGkmax=length(db);flag=0; % 1-> found a mag below lfg - 3.0for k=1:kmax i=k; if db(k) - lfg_db < -3.0 if k == 1 err=1; return end flag=1; break endend% see if we got through all points without finding a crossingif i == kmax if flag == 0 err=2; return endend% we have a crossing if got here, so find bandwidth by interpolationslope=(db(i)-db(i-1))/(omega(i)-omega(i-1));delta=(lfg_db-3.0-db(i-1))/slope;bw=omega(i-1)+delta;return%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -