Qurak

Work with nested lists

Anleitung 16 Schritte, der Reihe nach in einer Sitzung ausgeführt. Jeder Schritt wurde gegen die Engine ausgeführt, und die Ausgabe unten ist, was er erzeugte.

Schritt 1
alist = {{a1, a2, a3, a4}, {b1, b2, b3, b4}, {c1, c2, c3, c4}, {d1, d2, d3, d4}}
Ausgabe
{{a1, a2, a3, a4}, {b1, b2, b3, b4}, {c1, c2, c3, c4}, {d1, d2, d3, d4}}
Schritt 2
MatrixForm[alist]
Ausgabe
MatrixForm[{{a1, a2, a3, a4}, {b1, b2, b3, b4}, {c1, c2, c3, c4}, {d1, d2, d3, d4}}]
Schritt 3
alist[[2]]
Ausgabe
{b1, b2, b3, b4}
Schritt 4
alist[[2, 3]]
Ausgabe
b3
Schritt 5
alist[[All, 3]]
Ausgabe
{a3, b3, c3, d3}
Schritt 6
Flatten[alist]
Ausgabe
{a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4}
Schritt 7
MatrixForm[Flatten[alist]]
Ausgabe
MatrixForm[{a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4}]
Schritt 8
MatrixForm[{Flatten[alist]}]
Ausgabe
MatrixForm[{{a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4}}]
Schritt 9
data = Table[i + j, {i, 1, 5}, {j, 1, 4}]
Ausgabe
{{2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}, {5, 6, 7, 8}, {6, 7, 8, 9}}
Schritt 10
MatrixForm[data]
Ausgabe
MatrixForm[{{2, 3, 4, 5}, {3, 4, 5, 6}, {4, 5, 6, 7}, {5, 6, 7, 8}, {6, 7, 8, 9}}]
Schritt 11
ListLinePlot[data, AxesOrigin -> {0, 0}]
Ausgabe
-Graphics-
Schritt 12
Mean[data]
Ausgabe
{4, 5, 6, 7}
Schritt 13
Mean[Flatten[data]]
Ausgabe
11/2
Schritt 14
dat = Table[i + j + k, {i, 1, 4}, {j, 1, 4}, {k, 1, 4}];
MatrixForm[dat]
Ausgabe
MatrixForm[{{{3, 4, 5, 6}, {4, 5, 6, 7}, {5, 6, 7, 8}, {6, 7, 8, 9}}, {{4, 5, 6, 7}, {5, 6, 7, 8}, {6, 7, 8, 9}, {7, 8, 9, 10}}, {{5, 6, 7, 8}, {6, 7, 8, 9}, {7, 8, 9, 10}, {8, 9, 10, 11}}, {{6, 7, 8, 9}, {7, 8, 9, 10}, {8, 9, 10, 11}, {9, 10, 11, 12}}}]
Schritt 15
MatrixForm[Mean[dat]]
Ausgabe
MatrixForm[{{9/2, 11/2, 13/2, 15/2}, {11/2, 13/2, 15/2, 17/2}, {13/2, 15/2, 17/2, 19/2}, {15/2, 17/2, 19/2, 21/2}}]
Schritt 16
Mean[Flatten[dat]]
Ausgabe
15/2

Verwendete Funktionen

Verwandte Rezepte

Alle Rezepte · Funktionsreferenz · Dies aus einem MCP-Client verwenden