PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

426 Practical MATLAB® Applications for Engineers


Example 4.17

Let f(t) be the sum of two cosine waves with frequencies f 1 = 50 Hz and f 2 = 200 Hz, and
unit amplitudes.
Create the script fi le powers that returns over the range 0 ≤ t ≤ 15 s.


  1. The average power of f(t) using
    a. The norm function
    b. The MATLAB functions sum and abs

  2. The psd (power spectrum density) of f(t), using 1024 points, over the normalized
    range 0 ≤ w ≤ 1


MATLAB Solution
% Script file: powers
% echo off;
t = 0:0.01:15; % time sequence
x = 3*cos(2*pi*50.*t);
y = cos(2*pi*200.*t); ft=x+y;

FIGURE 4.72
(See color insert following page 374.) Plots of i(t), vl(t), vr(t), and vc(t) on the same plot (top), and verifi cation of
KVL (bottom) of Example 4.16.


20

10

− 10

− 20

0

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

0

0

5

10

− 10

− 5

0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time (sec)

Amplitude (amps/volts)

Amplitude (amps/volts)

Plots of: i(t) versus t, vr(t) versus t, vl(t) versus t, and vc(t) versus t

[vr(t)+vl(t)+vc(t)] versus t (verifies KVL)

i(t)
vr(t)

vc(t)
vl(t)
Free download pdf