4
$\begingroup$

I have a listo of 1000 numbers $\{x_0,x_1,\cdots,x_{999}\}$, I need to fill a matrix with these numbers. The matrix must have this form:

$$\left( \begin{array}{cccc} x_{9} &x_8 &\cdots& x_0 \\ x_{10} &x_9 &\cdots &x_1 \\ \dots & \cdots& \cdots &\cdots\\ x_{999} &x_{998} & \cdots& x_{990} \end{array}\right)$$

I have tried with

k = 0; line = {}; mat = {}; Do[ Do[AppendTo[line, x[[k + i]]], {i, 10}]; AppendTo[mat, line]; k = k + 1;, {j, 10}] 

but it is wrong

$\endgroup$

1 Answer 1

3
$\begingroup$

This will do it:

Reverse /@ Partition[Range[0, 999], 10, 1] 

{{9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, ... {999, 998, 997, 996, 995, 994, 993, 992, 991, 990}}

Replace Range[0, 999] by your x.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.