summaryrefslogtreecommitdiff
path: root/3793/CH6/EX6.8/exp_6_8.sce
blob: 7bda4e775cf5270e4e688ecbe7edfc0df094f38d (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
clear;
clc;
function [Zbus]=zeebus(nelemnt,ind,node);
    if ind==1;
        Zbus=input('Partial matrix Zbus');
        ind=0;
        else
    end
    if ind==0;
        for l=1:nelemnt;
            p=input('bus number p');
             q=input('bus number q');
             zb=input('impedence');
             typee=input('type of bus');
             if typee==1;
                 for k=1:q;
                     if k==q;
                         Zbus(k,k)=zb;
                     else
                         Zbus(k,q)=0;
                     end
                 end
             end
             if typee==2;
                 for k=1:q;
                     if k==q;
                         Zbus(q,q)=zb+Zbus(p,p);
                     else
                         if k==p;
                             Zbus(p,q)=Zbus(p,p);
                             Zbus(q,p)=Zbus(p,q);
                         else
                             Zbus(k,q)=0;
                             Zbus(q,k)=0;
                         end
                     end
                 end
             end
             if typee==3;
                 y=1/(zb+Zbus(p,p)-2*Zbus(p,q)+Zbus(q,q));
                 for k=1:node;
                     X(k,1)=Zbus(k,p)-Zbus(k,q);
                     Xt(1,k)=(k:1);
                 end
                 Zbus=Zbus-(-y)*X*X';
             end
             if typee==4;
                 y=1/(zb+Zbus(q,q));
                 for k=1:node;
                     X(k,1)=-Zbus(k,q);
                     Xt(1,k)=(k:1);
                 end
                 Zbus=Zbus-(-y)*X*X';
             end
         end
         else
                                     
            
    end
    
endfunction
nelemnt=7;
ind=0;
node=4;
[Zbus]=zeebus(nelemnt,ind,node);
mprintf("Zbus = \n");
disp(Zbus);
nelemnt=1;
ind=1;
[Zbus]=zeebus(nelemnt,ind,node);
disp(Zbus);