summaryrefslogtreecommitdiff
path: root/Working_Examples/215/CH2/EX2.1/ex2_1.sce
blob: b6e0cfdab805b0bb8fc99472cd5c71fc29718eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Example 2.1
//Computation of power absorbed by each part
//From figure 2.13a
V=2;I=3;
//We have Power(P)=V*I
P=V*I
printf("a) Power =%dW\n",P)
if P>0 then
    printf("Power is absorbed by the element\n")
else
    printf("Power is supplied by the element\n");
end 

clear P;
//From figure 2.13b
V=-2;I=-3;
//We have Power(P)=V*I
P=V*I
printf("b) Power =%dW\n",P)
if P>0 then
    printf("Power is absorbed by the element\n")
else
    printf("Power is supplied by the element\n")
end

//From figure 2.13c
V=4;I=-5;
//We have Power(P)=V*I
P=V*I
printf("c) Power =%dW\n",P)
if P>0 then
    printf("Power is absorbed by the element\n")
else
    printf("Power is supplied by the element\n")
end