Page 349 - Solutions Manual to accompany Electric Machinery Fundamentals
P. 349

(c)  A version of the program with 1000 Hz reference functions is shown below:

                 % M-file: probs1_15b.m
                 % M-file to calculate the output voltage from a PWM
                 % modulator with a 1000 Hz reference frequency.  Note
                 % that the only change between this program and that
                 % of part a is the frequency of the reference "fr".

                 % Sample the data at 20000 Hz to get enough information
                 % for spectral analysis.  Declare arrays.
                 fs = 20000;               % Sampling frequency (Hz)
                 t = (0:1/fs:4/15);        % Time in seconds
                 vx = zeros(size(t));      % vx
                 vy = zeros(size(t));      % vy
                 vin = zeros(size(t));     % Driving signal
                 vu = zeros(size(t));      % vx
                 vv = zeros(size(t));      % vy
                 vout = zeros(size(t));    % Output signal
                 fr = 1000;                % Frequency of reference signal
                 T = 1/fr;                 % Period of refernce signal

                 % Calculate vx at 1000 Hz.
                 for ii = 1:length(t)
                    vx(ii) = vref(t(ii),T);
                    vy(ii) = - vx(ii);
                 end

                 % Calculate vin as a 50 Hz sine wave with a peak voltage of
                 % 10 V.
                 for ii = 1:length(t)
                    vin(ii) = 10 * sin(2*pi*50*t(ii));
                 end

                                                           343
   344   345   346   347   348   349   350   351   352   353   354