1
$\begingroup$

Is there any way to make a bode plot without using the MATLAB/GNU Octave function bode()?

As an example, here is a function I am working on:

$$H(s) = \frac{1}{2s^2+3s+4}$$

$\endgroup$
4
$\begingroup$

Sounds like you want to omit the use of a MATLAB toolkit/Octave package. Of course you can build the bode diagram from scratch:

% transfert function as anonymous function
h = @(s)(1)./(2*s.^2+3*s+4);
% frequency vector
w = 2*pi*logspace(-2,2,1000);
% magnitude & phase estimation
mag = abs(h(1j*w));
magDB = 20*log10(mag);
phaseDeg = rad2deg(angle(h(1j*w)));

% plotting
clf;
subplot(211);
  semilogx(w/2/pi,magDB);
  xlabel('frequency [Hz]');
  ylabel('magniude [dB]');
  title('Bode diagram');
  grid on;
subplot(212);
  semilogx(w/2/pi,phaseDeg);
  xlabel('frequency [Hz]');
  ylabel('phase angle [°]');
  title('Phase diagram');
  grid on;

The equivalent code using bode() would be:

try
    pkg load control % required by octave
end

s = tf('s');
h = 1/(2*s^2+3*s+4);
bode(h);
| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy