0
$\begingroup$

My code is

$PrePrint = If[MatrixQ[#], MatrixForm[#], #] &;

t = {
    {-2,3,0,-3},
    {-1,-2,2,1},
    {-2,0,2,-1},
    {1,-3,1,3}
};

EVt  = Eigenvectors[t]

For[i=1,i<=2,i++,
    Indexed[EVt,i]
]

And my output ist.

{{-1, 1, 0, 2}, {1, 1, 2, 0}, {(-3 - I*Sqrt[3])/2, (-1/2*I)*(I + Sqrt[3]), (-1 - I*Sqrt[3])/2, 1}, {(-3 + I*Sqrt[3])/2, (I/2)*(-I + Sqrt[3]), (-1 + I*Sqrt[3])/2

Note because of the PrePrint it is actually in a "nice" matrix shape. What I now want is, every vector printed on its own. But the For loop just outputs nothing. I'm an absolut beginner in Mathematica so I don't understand, what I'm doing wrong.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

You need to tell MMA to print a value inside a for loop. And indexing is easily done using [[...]]

For[i = 1, i <= 4, i++, Print[EVt[[i]]]]

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ Print /@ EVt; is more straightforward than For. $\endgroup$
    – Bob Hanlon
    Commented Mar 24, 2022 at 16:32
  • $\begingroup$ Thank you for you answers. I have several follow up questions. 1. Using Print[EVt[[i]]] it only outputs the first two vectors. While Print /@ EVt; outputs all 4 of them. Why? 2. Using Print makes them be in the { } format like in Daniel Hubers answer. But I'd like them to be in a "nice" Matrix format. How can I achieve that? $\endgroup$
    – Akut Luna
    Commented Mar 25, 2022 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.