Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

An Eigenvalue and Eigenvector can be derived from the Tensor T by the below equation.

I am trying to get a system of equations for Eigenvalues, Eigenvectors and the Tensor T to derive T.

T matrix equation is:

(T(i,k)-L(r)*I) * A(r,k) = 0

The first entries should be:

[(T11-L1)*A11 T12*A12       T13*A13        T14*A14     ]
[T21*A11      (T22-L1)*A12  T23*A13        T24*A14     ]   
[T31*A11      T32*A12       (T33-L1)*A13   T34*A14     ]
[T41*A11      T42*A12       T43*A13        (T44-L1)*A14]
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
281 views
Welcome To Ask or Share your Answers For Others

1 Answer

First, let's declare the symbolics easier using sym:

T = sym('T%d%d', [4 4]);
A = sym('A%d%d', [4 4]);
L = sym('L', [4 1]);

There are several problems with the original code; 1. f is being replaced in each inner iteration. 2. The inner result should be scalar and thus I must not appear there. (Note that you can also define I like eye(4) instead of writing it manually.)

Here is the corrected version:

f = cell(4,1); % Initialize equation system

for r = 1:k
    for k = 1:4
        for i = 1:4
            f{r}(i,k) = T(i,k) * A(r,k);
        end
    end
    f{r} = f{r} - L(r)*diag(A(r,:));
end

f{i} would be the ith slice.

Note: As @Schorsch pointed out (and Matlab also shows a warning) always try to use another variable name other than i (or j), since they represent the imaginary unit.

Just for fun you can use repmat to remove the two inner loops:

for r = 1:4
    f{r} = T .* repmat(A(r,:), [4 1]) - L(r)*diag(A(r,:));
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...