Skip to content

Instantly share code, notes, and snippets.

@eggie5
Created April 26, 2013 19:22
Show Gist options
  • Select an option

  • Save eggie5/5469705 to your computer and use it in GitHub Desktop.

Select an option

Save eggie5/5469705 to your computer and use it in GitHub Desktop.
w = logspace(-1,5,50);
for i = 1:length(w)
if (w(i) <= 36)
magn(i) = 20*log10(w(i)) + 20*log10(92)
elseif (w(i) <= 1800)
magn(i) = 20*log10(w(i)) + 20*log10(92) -20*log10(w(i)/36)
elseif (w(i) <=100000)
magn(i) = 20*log10(w(i)) + 20*log10(92) -20*log10(w(i)/36) -20*log10(w(i)/1800)
else
magn(i)=0
end
end
subplot(2,2,1);
semilogx(w,magn); grid; hold on;
tf1 = tf(1,[1 36]); [mag1,phase1] = bode(tf1,w); % compute the phase of the 1st term
tf2 = tf(1,[1 1800]); [mag2,phase2] = bode(tf2,w); % compute the phase of the 2nd term
totalph = phase1 + phase2; % add these up to get the total phase
subplot(2,2,2);
semilogx(w, totalph(1,:)); grid; hold on
H=tf([92 0],[1/64800 17/600 1])
subplot(2,2,3);
bodemag(H)
subplot(2,2,4);
h=bodeplot(H)
setoptions(h,'MagVisible','off');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment