• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Sep 15th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. clc
2. V_t=26e-3;
3. I_s=1e-6;
4. I_d=0.1
5. V_d=V_t*log(1 + I_d/I_s)
6. G_eq=I_s/V_t*exp(V_d/V_t)
7. I_eq=I_d- G_eq*V_d
8. I_dold = 1;
9. R = [1 2 1];
10. V = [1 0 1];
11. d = [2 0];
12. abs(I_dold - I_eq)
13.
14. c = 1;
15.
16. n = max([max(R(:, 1: 2)) max(V(:, 1:2)) max(D)]);
17. m = size(V, 1);
18. while(abs(I_dold-I_d)>1e-1)
19. A = zeros(n + m);
20. G = zeros(n);
21. B = zeros(n, m);
22. C = zeros(m, n);
23. D = zeros(m, m);
24.
25. for i = 1 : size(R, 1)
26.    n1 = R(i, 1)
27.    n2 = R(i, 2)
28.    g = 1/R(i, 3)
29.    if(n1 == 0)
30.        G(n2, n2) = G(n2, n2) + g
31.    elseif (n2 == 0)
32.        G(n1, n1) = G(n1, n1) + g
33.    else
34.        G(n1, n2) = G(n1, n2) - g
35.        G(n2, n1) = G(n2, n1) - g
36.        G(n2, n2) = G(n2, n2) + g
37.        G(n1, n1) = G(n1, n1) + g
38.    end
39. end
40. G
41. for i = 1 : size(d, 1)
42.    np = d(i, 1);
43.    nn = d(i, 2);
44.    g  = G_eq;
45.    if(np == 0)
46.        G(nn, nn) = G(nn, nn) + g
47.    elseif (nn == 0)
48.        G(np, np) = G(np, np) + g
49.    else
50.        G(np, nn) = G(np, nn) - g
51.        G(nn, np) = G(nn, np) - g
52.        G(nn, nn) = G(nn, nn) + g
53.        G(np, np) = G(np, np) + g
54.    end
55.
56. end
57. G
58.
59.
60. for i = 1 : size(V, 1)
61.    nplus = V(i, 1);
62.    nminus = V(i, 2);
63.    if (nplus == 0)
64.        B(nminus, i) = B(nminus, i) - 1;
65.    elseif (nminus == 0)
66.        B(nplus, i) = B(nplus, i) + 1;
67.    else
68.        B(nminus, i) = B(nminus, i) - 1;
69.        B(nplus, i) = B(nplus, i) + 1;
70.    end
71. end
72. B
73.
74. C = B';
75.
76. A = [G B; C D]
77.
78. z = zeros(n + m, 1);
79. i = zeros(n, 1);
80. e = zeros(m, 1);
81.
82. for j = 1 : size(V, 1)
83.    e(j) = V(j, 3);
84. end
85.
86. for k = 1 : size(i, 1)
87.    for j = 1 : size(d, 1)
88.       if d(j, 1) == k
89.           i(k) = i(k) - I_eq;
90.       elseif d(j, 2) == k
91.           i(k) = i(k) + I_eq;
92.       end
93.    end
94. end
95.
96. z = [i; e]
97.
98. X = inv(A)*z
99.
100. I_dold = I_eq
101. I_eq = -X(end);
102. V_d=V_t*log(1 + I_eq/I_s)
103. G_eq=I_s/V_t*exp(V_d/V_t)
104. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top