% Filename: example9.m % % Description: This m-file plots the spectra (frequency response) % of a DC Motor. clear; % clear matlab memory KT = 4.07; % motor torque constant L = 0.00156; % motor inductance J = 2*pi*1000*0.00059/60; % motor rotor inertia (converted to % units of oz.in.sec/krpm) R = 1.89; % motor resistance B = 6.68; % motor friction Kb = 3.01; % motor back emf constant num = [KT]; % numerator of motor TF den = [L*J R*J+B*L B*R+KT*Kb]; % denominator of motor TF printsys(num,den,'s'); % display H(s) w = -2000:1:2000; % frequency range H = polyval(num,j*w)./polyval(den,j*w);% FT of h(t), H(w) figure(1); clf; % open and clear figure 1 subplot(2,1,1); % plot magnitude of H(w) plot(w,abs(H)); grid; xlabel('\omega (rad/sec)'); ylabel('|H(\omega)|'); title('Magnitude of H(\omega)'); subplot(2,1,2); % plot phase of H(w) plot(w,angle(H)*180/pi); grid; xlabel('\omega (rad/sec)'); ylabel('\angle(H(\omega)) (deg)'); title('Phase of H(\omega)'); figure(2); clf; % open and clear figure 2 subplot(2,1,1); % plot poles & zeros of H(w) pzmap(num,den); title('Pole-Zero Diagram'); t = 0:0.00005:0.03; % plot response to Va=15u(t) y = step(num*12,den,t); subplot(2,1,2); plot(t,y); grid; xlabel('time (sec)'); ylabel('Motor Speed (krpm)'); title('Motor Step Response for v_a=12u(t)');Matlab Response Generated:
num/den = 4.07 ------------------------------------- 9.6384e-005 s^2 + 0.12719 s + 24.8759MATLAB Plots Generated: