25b_BodeCHE361W12

25b_BodeCHE361W12 - Page 1 of 2 % BodeCHE361.m % % % % % A...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Page 1 of 2 % BodeCHE361.m % % % % % A simple program to make a Bode plot for first-order process using MATLAB bode function and using "short-cut" method for first-order with time delay process. Dr. K.L. Levien, Oregon State University Chemical Engineering CHE 361 % Use 501 frequencies from 10^-3 to 10^2 rad/min omega = logspace(-3,2,501); % logspace selects values equally spaced by log10 values % Specify a numerator polynomial and a denominator polynomial for G(s) num = [5]; % numerator polynomial in s den = [10 1]; % denominator polynomial in s [AR,PA,omega] = bode(num,den,omega); % uses MATLAB function bode for no time delay % AR = amplitude ratio % PA = phase angle figure % opens a new MATLAB figure window subplot(2,1,1) % 2,1 = 2 rows x 1 column (top and btm plot), 1 = top loglog(omega,AR) % log10 axis on x and y axis([0.001 10 0.1 10]) % fix axis min/max for x axis and y axis title(['Freq. Resp. G(s), num = [' num2str(num) '] , den = [' num2str(den) ']']) ylabel('Amplitude Ratio'), fnicefig % subplot(2,1,2) % 2,1 = 2 rows x 1 column (top and btm plot), 2 = btm semilogx(omega,PA) % log10 axis only on x axis axis([0.001 10 -180 0]) % fix axis min/max for x axis and y axis xlabel('Frequency (rad/min)'), ylabel('Phase Angle (degrees)'), fnicefig % Now the "short-cut method" for a first-order plus time delay s = j*omega; % creates a vector of imaginary numbers as s K = 5; % same as numerator for example above (dimensionless) tau = 10; % same as denominator for example above (minutes) theta = 0.2; % time delay (minutes) G = (K*exp(-theta*s))./(tau*s+1); % element-by-element division AR2 = abs(G); % amplitude ratio = magnitude of complex numbers in G vector PArad = angle(G); % phase angle = polar angle of complex numbers in G % use unwrap to track large negative angles % convert from radians to degrees for Bode plot PA2 = unwrap(PArad)*180/pi; figure % opens a second MATLAB figure window subplot(2,1,1) % 2,1 = 2 rows x 1 column (top and btm plot), 1 = top loglog(omega,AR2) % log10 axis on x and y axis([0.001 10 0.1 10]) % fix axis min/max for x axis and y axis title('Short-cut Freq. Resp. G(s), K = 5, tau = 10, time delay = 0.2') ylabel('Amplitude Ratio'), fnicefig % subplot(2,1,2) % 2,1 = 2 rows x 1 column (top and btm plot), 2 = btm semilogx(omega,PA2) % log10 axis only on x axis axis([0.001 10 -180 0]) % fix axis min/max for x axis and y axis xlabel('Frequency (rad/min)'), ylabel('Phase Angle (degrees)'), fnicefig Page 2 of 2 Amplitude Ratio 10 10 10 Freq. Resp. G(s), num = [5] , den = [10 1] 1 0 -1 10 -3 10 -2 10 -1 10 0 10 1 0 Phase Angle (degrees) -20 -40 -60 -80 -100 -120 -140 -160 -180 -3 10 Amplitude Ratio 10 10 10 10 -2 -1 10 Frequency (rad/min) 10 0 10 1 Short-cut Freq. Resp. G(s), K = 5, tau = 10, time delay = 0.2 1 0 -1 10 -3 10 -2 10 -1 10 0 10 1 0 Phase Angle (degrees) -20 -40 -60 -80 -100 -120 -140 -160 -180 -3 10 10 -2 -1 10 Frequency (rad/min) 10 0 10 1 ...
View Full Document

Ask a homework question - tutors are online