Advertisement
pVinc

zgoda

Nov 2nd, 2021
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.65 KB | None | 0 0
  1. N = 4;
  2.             numericUpDown1.Value = N;
  3.             UstawTablice();
  4.             int blad;
  5.             double R1, R2, R3, R4, R5, L, C, XL, XC, E1, E2, ZE1, ZE2;
  6.             Complex ComplexE2, ComplexE1;
  7.             AZ = new Complex[N + 1, N + 1];
  8.             BZ = new Complex[N + 1];
  9.             XZ = new Complex[N + 1];
  10.             E1 = 10;
  11.             E2 = 10;
  12.             R1 = 10;
  13.             R2 = 10;
  14.             R3 = 10;
  15.             R4 = 10;
  16.             R5 = 10;
  17.             XL = 10;
  18.             XC = 10;
  19.             ZE1 = 5;
  20.             ZE2 = 10;
  21.             ComplexE1 = new Complex(E1, ZE1);
  22.             ComplexE2 = new Complex(E2, ZE2);
  23.  
  24.             AZ[1, 1] = new Complex(1, 0);
  25.             AZ[1, 2] = new Complex(-1, 0);
  26.             AZ[1, 3] = new Complex(-1, 0);
  27.             AZ[1, 4] = new Complex(1, 0);
  28.  
  29.             BZ[1] = new Complex(0, 0);
  30.  
  31.             AZ[2, 1] = new Complex(R1, -XC);
  32.             AZ[2, 2] = new Complex(R2, 0);
  33.             AZ[2, 3] = new Complex(0, 0);
  34.             AZ[2, 4] = new Complex(0, 0);
  35.  
  36.             BZ[2] = new Complex(E1, ZE1);
  37.  
  38.             AZ[3, 1] = new Complex(0, 0);
  39.             AZ[3, 2] = new Complex((-R2), 0);
  40.             AZ[3, 3] = new Complex(R3, 0);
  41.             AZ[3, 4] = new Complex(0, 0);
  42.  
  43.             BZ[3] = new Complex(E2, ZE2);
  44.  
  45.             AZ[4, 1] = new Complex(0, 0);
  46.             AZ[4, 2] = new Complex(0, 0);
  47.             AZ[4, 3] = new Complex(R3, 0);
  48.             AZ[4, 4] = new Complex(R4+R5, XL);
  49.  
  50.             BZ[4] = new Complex(E2, ZE2);
  51.  
  52.  
  53.  
  54.             for (int i = 1; i <= N; i++)
  55.             {
  56.                 for (int j = 1; j <= N; j++)
  57.                 {
  58.                     MacierzA.Rows[i - 1].Cells[j - 1].Value = AZ[i, j].ToString();
  59.                 }
  60.                 WektorB.Rows[i - 1].Cells[0].Value = BZ[i].ToString();
  61.             }
  62.             if (radioButton1.Checked) blad = MetodaGaussa.RozRowMacGaussa(AZ, BZ, XZ, 1e-30);
  63.             else blad = MetodaRozkladuLU.RozRowMacCroutDoolitta(AZ, BZ, XZ, 1e-30);
  64.             if (blad == 0)
  65.                 for (int i = 1; i <= N; i++)
  66.                     WektorX[0, i - 1].Value = XZ[i].ToString("0.0000000");
  67.             textBox1.Text = "Ipk bilans =" + (XZ[1] - XZ[2] - XZ[3] + XZ[4]);
  68.             textBox2.Text = "IIpk bilans =" + (ComplexE1 - XZ[1]*(R1 - Complex.j*XC) - XZ[2]*R2);
  69.             textBox3.Text = "Moc odbiorników = " + ((XZ[1]*XZ[1].Conjugate)*(R1-Complex.j*XC) + (XZ[2] * XZ[2].Conjugate)*R2 + (XZ[3] * XZ[3].Conjugate)*R3 + (XZ[4] * XZ[4].Conjugate)*(R4+R5+Complex.j*XL));
  70.             textBox4.Text = "Moc źródeł = " + ((ComplexE1 * XZ[1].Conjugate) + (ComplexE2 * XZ[3].Conjugate));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement