P 7.3-1 The current, i, through a capacitor is shown in Figure P 7.3-1. When v(0) = 0 and C = 0.5 F, determine and plot v(t), p(t), and w(t) for 0 s < t < 6 s.

 

c07f089.eps

Figure P 7.3-1

We have two constant current pieces and one linear piece.  Use points (2 s, 0 A) and

(6 s, 0.8 A)  Equation of a line can be found from

 

 

So we can write the current equation as

 

 

 

 

And

 

 

 

 

 

And

 

 

 

 

 

So the voltage is

 

 

For Power we can use

 

 

 

 

 

 

 

 

 

For Energy w(t) use

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MATLAB Plot Follows.  One m-file makes all the plots in this homework.

 

 

Note there is another way to obtain this plot and that is to just let MATALB multiply and plot so

 

So the stripes are due to putting two functions on the plot, one from the direct equation given above and the other to using the relationship above.  As expected the same plot results.

 

MATLAB Plot Follows.  One m-file makes all the plots in this homework.

 

 

Note there is another way to obtain this plot and that is to just let MATALB multiply and plot so

 

So the stripes are due to putting two functions on the plot, one from the direct equation given above and the other to using the relationship above.  As expected the same plot results.

 

MATLAB Plot Follows.  One m-file makes all the plots in this homework.

 

Here is a plot of all four electrical quantities

 

Here is the MATLAB Code for these plots

 

%Program to solve PH 320 Homework Problem P7.3-1

%version 2019-04-04 DW Donovan

clear all;

 

C = 0.5;

t1 = [0: 0.001: 2]';

t2 = [2: 0.001: 6]';

t3 = [6: 0.001: 8]';

t = [t1' t2' t3']';

 

%Current Function

i1 = 0*t1;

i2 = 0.2*(t2 - 2);

i3 = 0.8*t3./t3;

i = [i1' i2' i3']';

 

 

 

 

 

 

%VOltage Function

v1 = 0*t1;

v2 = 0.2*(t2.^2 - 4*t2 + 4);

v3 = 1.6*t3 - 6.4;

v = [v1' v2' v3']';

 

%Power Function Direct - a

p1a = 0*t1;

p2a = 0.04*t2.^3 - 0.24*t2.^2 + 0.48*t2 - 0.32;

p3a = 1.28*t3 - 5.12;

pa = [p1a' p2a' p3a']';

 

%Power Function - Mutliply - b

p1b = i1.*v1;

p2b = i2.*v2;

p3b = i3.*v3;

pb = [p1b' p2b' p3b']';

 

%Energy Function Direct - a

w1a = 0*t1;

w2a = 0.01*t2.^4 - 0.08*t2.^3 + 0.24*t2.^2-0.32*t2+0.16;

w3a = 0.64*t3.^2 - 5.12*t3 + 10.24;

wa = [w1a' w2a' w3a']';

 

%Energy Function - Multiply - b

w1b = 0.5*C*v1.^2;

w2b = 0.5*C*v2.^2;

w3b = 0.5*C*v3.^2;

wb = [w1b' w2b' w3b']';

 

%Axis Labels, Title and Legend Strings

xt = 'Time, t, (s)';

yi = 'Current, i, (A)';

yv = 'Voltage, v. (V)';

yp = 'Power, P, (W)';

yw = 'Energy, w, (J)';

ya = 'Electrical Properties in their own units';

tt2 = ['\newline PH 320 Homework Problem 7.3-1'];

tt3 = ['\newline D.W. Donovan - ' date];

tti = ['Current vs Time plot'];

ttv = ['Voltage vs Time plot'];

ttp = ['Power vs Time plot'];

 

ttw = ['Energy vs Time plot'];

tta = ['All Electrical Properties on one plot'];

li = 'Current';

lv = 'Voltage';

lpa = 'Power Direct';

lpb = 'Power Multiply';

lwa = 'Energy Direct';

lwb = 'Energy Multiply';

 

 

figure

plot (t, i, 'k-','LineWidth', 4)

ttpi =[tti tt2 tt3];

title (ttpi)

xlabel (xt)

ylabel (yi)

 

figure

plot (t, v, 'k-', 'LineWidth',4)

ttpv = [ttv tt2 tt3];

title (ttpv)

xlabel (xt)

ylabel (yv)

 

figure

hold on

plot (t, pa, 'k-','LineWidth',4)

plot (t, pb, 'r--','LineWidth',4)

ttpp = [ttp tt2 tt3];

title (ttpp)

xlabel (xt)

ylabel (yp)

 

figure

hold on

plot (t, wa, 'k-','LineWidth',4)

plot (t, wb, 'b--','LineWidth',4)

ttpw = [ttw tt2 tt3];

title (ttpp)

xlabel (xt)

ylabel (yw)

 

 

 

figure

hold on

plot (t, i, 'c-','LineWidth', 4)

plot (t, v, 'g-', 'LineWidth',4)

plot (t, pa, 'k-','LineWidth',4)

plot (t, pb, 'r--','LineWidth',4)

plot (t, wa, 'k-','LineWidth',4)

plot (t, wb, 'b--','LineWidth',4)

ttpa = [tta tt2 tt3];

title (ttpa)

xlabel (xt)

ylabel (ya)

legend (li, lv, lpa, lpb, lwa, lwb,'Location', 'NW')

legend ('boxoff')

 

 

 

 

Please send any comments or questions about this page to ddonovan@nmu.edu

This page last updated on April 5, 2019