Advertisement
pVinc

Mortka

Oct 20th, 2021
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. N = 3;
  2.             numericUpDown1.Value = N;
  3.             UstawTablice();
  4.             int blad;
  5.             AZ = new Complex[N + 1, N + 1];
  6.             BZ = new Complex[N + 1];
  7.             XZ = new Complex[N + 1];
  8.  
  9.             Complex E1 = 10;
  10.             Complex E2 = 10;
  11.             double R = 10;
  12.             double Rc = 10;
  13.             double Rl=10;
  14.  
  15.             BZ[1] = Complex.Zero;
  16.             BZ[2] = E1;
  17.             BZ[3] = E2;
  18.  
  19.             AZ[1, 1] = 1;
  20.             AZ[1, 2] = -1;
  21.             AZ[1, 3] = -1;
  22.  
  23.             AZ[2, 1] = R;
  24.             AZ[2, 2] = 0;
  25.             AZ[2, 3] = new Complex(0, -Rc);
  26.  
  27.             AZ[3, 1] = 0;
  28.             AZ[3, 2] = new Complex(0, Rl);
  29.             AZ[3, 3] = new Complex(0, Rc);
  30.  
  31.             for (int i = 1; i <= N; i++)
  32.             {
  33.                 for (int j = 1; j <= N; j++)
  34.                 {
  35.                     MacierzA.Rows[i-1].Cells[j-1].Value = AZ[i,j].ToString();
  36.                 }
  37.                 WektorB.Rows[i - 1].Cells[0].Value = BZ[i].ToString();
  38.             }
  39.             if (radioButton1.Checked)
  40.             {
  41.                 blad = MetodaGaussa.RozRowMacGaussa(AZ, BZ, XZ, 1e-30);
  42.             }
  43.             else
  44.             {
  45.                 blad = MetodaRozkladuLU.RozRowMacCroutDoolitta(AZ, BZ, XZ, 1e-30);
  46.             }
  47.             if (blad == 0)
  48.                 for (int i = 1; i <= N; i++)
  49.                     WektorX[0, i - 1].Value = XZ[i].ToString("0.000000");
  50.  
  51.            
  52.             textBox1.Text = "IpK bilans: " + (XZ[1] - XZ[2] - XZ[3]).ToString();
  53.             textBox2.Text = "IIpK bilans: " + (XZ[3]*(-Complex.j * Rc) - XZ[2]*(Complex.j * Rl) + E2).ToString();
  54.  
  55.             double Pz = (E1*XZ[1].Conjugate + E2*XZ[2].Conjugate).Re;
  56.             double Podb = (XZ[1] * XZ[1].Conjugate * R).Re + (XZ[2] * XZ[2].Conjugate * (Complex.j * Rl)).Re + (XZ[3] * XZ[3].Conjugate * (-Complex.j * Rc)).Re;
  57.             textBox3.Text = "  Pz = " + Pz.ToString();            
  58.             textBox4.Text = "Podb = " + Podb.ToString();
  59.            
  60.             Complex Sz = new Complex(0, 0);
  61.             Sz = E1 * XZ[1].Conjugate + E2 * XZ[2].Conjugate;
  62.             Complex Sodb = new Complex(0, 0);
  63.             Sodb = (XZ[1] * XZ[1].Conjugate * R) + (XZ[2] * XZ[2].Conjugate * (Complex.j * Rl)) + (XZ[3] * XZ[3].Conjugate * (-Complex.j * Rc));
  64.             textBox5.Text = "  Sz= " + Sz.ToString();
  65.             textBox6.Text = "Sodb = " + Sodb.ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement