Subscribe Bookmark RSS Feed

print iteration output into one single matrix

Highlighted
xenoirita

Community Trekker

Joined:

Feb 24, 2013

Hi,

How do I get the iteration output into one single matrix with format 3-columns and n-rows?  The column1 , column2 and column3 are filled with x(i), y(i), z(i) respectively.

n = 6;

x_i = J (1,n);

y_i = J (1,n);

z_i = J (1,n);

For(i = 0, i <=n , i++,

     x_i = 38 + (i*5.0);

     y_i = 45 + 3*(x_i) ;

     z_i = 80 + 10*(x_i) ;

  );

mymatrix = [x_i , y_i,  z_i];

print (mymatrix);

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

This should work:

n = 6;

x_i = J( 1, n );

y_i = J( 1, n );

z_i = J( 1, n );

For( i = 1, i <= n, i++,

  x_i[i] = 38 + (i * 5.0);

  y_i[i] = 45 + 3 * (x_i)[i];

  z_i[i] = 80 + 10 * (x_i)[i];

);

mymatrix = Transpose( x_i |/ y_i |/ z_i );

Print( mymatrix );

2 REPLIES
Solution

This should work:

n = 6;

x_i = J( 1, n );

y_i = J( 1, n );

z_i = J( 1, n );

For( i = 1, i <= n, i++,

  x_i[i] = 38 + (i * 5.0);

  y_i[i] = 45 + 3 * (x_i)[i];

  z_i[i] = 80 + 10 * (x_i)[i];

);

mymatrix = Transpose( x_i |/ y_i |/ z_i );

Print( mymatrix );

xenoirita

Community Trekker

Joined:

Feb 24, 2013

Thanks, MS!