Find the set of eigenvectors of a 4x4 matrix elements whose matrix elements have some VARIABLE PARAMETERS.

6 ビュー (過去 30 日間)
Muhsin
Muhsin 2022 年 11 月 11 日
編集済み: Torsten 2022 年 11 月 12 日
Below is how I defined the matrix. It is a 4x4 matrix with variables B and N on the off diagonal. Since each of these variable takes certain values in a given range, my goal is to read and display the eigenvectors for each of the values in the range of the variables.
delta=45;
%create a 4x4 zeros matrix
mat=zeros(4,4);
%set values for corresponding entries of the matrix
mat(1,1)= delta;
mat(1,2)= 0 ;
mat(1,3)=0;
mat(2,1)=0 ;
mat(2,2)= delta;
mat(2,4)=0;
mat(3,1)=0;
mat(3,3)= -delta;
mat(3,4)= 0 ;
mat(4,2)=0;
mat(4,3)=0 ;
mat(4,4)= -delta;
%define the off diagonal elements of the matrix
for N = 0:1:5
for B = 0:0.001:10
mat(1,4)=sqrt(750*B*N);
mat(2,3)=sqrt(750*B*N);
mat(3,2)=sqrt(750*B*N);
mat(4,1)=sqrt(750*B*N);
end
end
  2 件のコメント
John D'Errico
John D'Errico 2022 年 11 月 11 日
Please don't ask this same question any more times.
Muhsin
Muhsin 2022 年 11 月 11 日
My bad!
I realized I could edit the original question after I did it.

サインインしてコメントする。

回答 (3 件)

Jon
Jon 2022 年 11 月 11 日
If I understand what you are trying to do I think this should do what you want.
The resulting values of the eigenvector for each value of the parameter B*N will be stored in the columns of matrix V
delta=45;
%set values for corresponding diagonal entries of the matrix
mat = diag([delta,delta,-delta,-delta]);
% define vectors of variable parameters
N = 0:1:5;
B = 0:0.001:10;
% matrix is parameterized by product B*N, so just compute for unique
% values of this parameter
BN = unique(N'*B);
%define the off diagonal elements of the matrix and compute the
%eigenvectors
numParam = numel(BN); % number of parameter values to be evaluated
V = zeros(4,numParam); % preallocate array to hold eigenvectors
for k = 1:numParam
a = sqrt(750*BN(k));
mat(1,4)=a;
mat(2,3)=a;
mat(3,2)=a;
mat(4,1)=a;
V(:,k) = eig(mat);
end
  3 件のコメント
Jon
Jon 2022 年 11 月 11 日
編集済み: Jon 2022 年 11 月 11 日
Yes, good catch. The syntax seems a little strange with this, e = eig(A) returns a vector of eigen values, and so does [e] = eig(A), but [V,~]=eig(A) returns the matrix of eigenvectors. So even though in both cases we look at the first returned argument, the definition changes. So you must use the two argument calling syntax to get the eigenvectors.
This also means you need to store a matrix of Eigenvectors for each value of B*N, here is some modified code where I store the matrices of eigenvectors in a 3d array (each page is for a value of B*N).
So if you wanted look at the eigenvectors corresponding to BN(3) you would look at V(:,:,3)
delta=45;
%set values for corresponding diagonal entries of the matrix
mat = diag([delta,delta,-delta,-delta])
% define vectors of variable parameters
N = 0:1:5;
B = 0:0.001:10;
% matrix is parameterized by product B*N, so just compute for unique
% values of this parameter
BN = unique(N'*B);
%define the off diagonal elements of the matrix and compute the
%eigenvectors
numParam = numel(BN); % number of parameter values to be evaluated
V = zeros(4,4,numParam); % preallocate array to hold eigenvectors
for k = 1:numParam
a = sqrt(750*BN(k));
mat(1,4)=a;
mat(2,3)=a;
mat(3,2)=a;
mat(4,1)=a;
[V(:,:,k),~] = eig(mat);
end
Muhsin
Muhsin 2022 年 11 月 11 日
Thanks.
[V(:,:,k),~] = eig(mat); is a significant improvement. It, returns a set of eigenvectors but they are the same eigenvectors repeated. Some of the values of the eigenvectors are controlled by B*N, hence the eigenvectors shouldn't be exactly the same.

サインインしてコメントする。


Torsten
Torsten 2022 年 11 月 11 日
編集済み: Torsten 2022 年 11 月 12 日
I set a = sqrt(750*B*N) in the below code. So for every combination of B and N, it gives you the eigenvalues (diagonal of D) and eigenvectors (columns of V) of your matrix "mat".
syms delta a real
mat = delta*sym(eye(4));
mat(3,3) = -mat(3,3);
mat(4,4) = -mat(4,4);
mat(1,4) = a;
mat(4,1) = a;
mat(3,2) = a;
mat(2,3) = a;
[V,D] = eig(mat)
V = 
D = 
simplify(mat*V-V*D)
ans = 
  4 件のコメント
Jon
Jon 2022 年 11 月 11 日
編集済み: Jon 2022 年 11 月 11 日
@TorstenIt seems that when I explicitly loop through the BN combinations (code in my answer) the eigenvectors the eigenvectors do seem to depend upon "a" (the value of B*N). Did I do something wrong or miss something?
Torsten
Torsten 2022 年 11 月 12 日
編集済み: Torsten 2022 年 11 月 12 日
I misread
mat = diag([delta,delta,delta,delta]);
instead of
mat = diag([delta,delta,-delta,-delta]);
But nevertheless, after incorporating the changes in the symbolic computation (see above), the results are still easy to implement for the numerical case.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2022 年 11 月 11 日

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by