c# - how to write the value to each matrix index -


for example, have set formula find xnew[k+1], ynew[k+1] , anew[k+1].

how pass value 3 1 matrix if want

  • index 1,1 xnew[k+1],
  • index 1,2 ynew[k+1],
  • index 1,3 anew[k+1].

here's got far.

for (k = 0; k < 5; k++) {     xnew[k+1] = cx + (t * mpcv[k]) * math.cos(ca);     ynew[k+1] = cy + (t * mpcv[k]) * math.sin(ca);     anew[k+1] = ca + (t * mpcw[k]);      double[,] qk = new double[3, 1];     int i, j;     (i = 0; < 3; i++)     {         (j = 0; j < 1; j++)         {             qk[i, j] = 1;         }     } } 

thank help.

suposing xnew[k+1], ynew[k+1] , anew[k+1] doubles:

for ( k = 0; k < 5; k++ ) {     xnew[k + 1] = cx + (t * mpcv[k]) * math.cos(ca);     ynew[k + 1] = cy + (t * mpcv[k]) * math.sin(ca);     anew[k + 1] = ca + (t * mpcw[k]);      double[,] qk = { { xnew[k + 1] ,  ynew[k + 1] ,  anew[k + 1] } }; } 

this make 1x3 matrix (arrays start in 0) with:

  • qk[0,0] = xnew[k+1]
  • qk[0,1] = ynew[k+1]
  • qk[0,2] = anew[k+1]

but if want 3x1 matrix use instead.

 double[,] qk = { { xnew[k + 1] },  {ynew[k + 1] },  {anew[k + 1] } }; 

that give you:

  • qk[0,0] = xnew[k+1]
  • qk[1,0] = ynew[k+1]
  • qk[2,0] = anew[k+1]

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -