Creating Matrix provided elements

2 Ansichten (letzte 30 Tage)
Karthik Nagaraj
Karthik Nagaraj am 22 Jul. 2021
Kommentiert: Karthik Nagaraj am 24 Jul. 2021
From a Hermititan (complex skew symmetric) matrix of order N (Asssume N=15) a column vector is created such that all the diagonal elements are placed first and then the ordered pair of real and imaginary parts of upper triangle matrix are placed next. Since it is hermitian matrix the upper and lower triangle elements have same set of real and imaginary elements.
For example for N=15x15 matrix the vector looks like this
[D1, D2, D3,...........,D15, R11, I11,R12, I12,.... ,R15, I15] in total 225 elements column vector.
How to construct back the matrix given this vector?
  4 Kommentare
Jan
Jan am 23 Jul. 2021
What is R1_2 compared to L1_2? Should it be L2_1? If it is a hermitian matrix, why are the L elements stored?
Please explain exactly, what the inputs are. Use a 4x4 matrix to avoid the need to use unclear abbreviations.
Karthik Nagaraj
Karthik Nagaraj am 23 Jul. 2021
Bearbeitet: Karthik Nagaraj am 23 Jul. 2021
Hermitian Matrix N=4. Always Diagonal are real. Upper triangle elements are complex conjuagte of Lower triangle elements
disp(H)
0.9490 + 0.0000i -0.0222 + 0.8156i -1.2365 + 0.4256i -0.1310 - 0.4833i
-0.0222 - 0.8156i 0.3080 + 0.0000i -0.0918 + 1.2658i -0.3776 - 0.1952i
-1.2365 - 0.4256i -0.0918 - 1.2658i -0.9261 + 0.0000i -0.0571 - 0.9267i
-0.1310 + 0.4833i -0.3776 + 0.1952i -0.0571 + 0.9267i 0.2858 + 0.0000i
I have created a funciton that can extract Diagonal elements, Upper triangle elements in ordered pair (R-Real and I-Imaginary element one after the other and form a vector of these.
Diagonal elements
disp(D)
0.9490
0.3080
-0.9261
0.2858
Upper triangle elements ordered pair. Real and imaginary pair next to each other
disp(UOP)
-0.0222 0.8156 -1.2365 0.4256 -0.0918 1.2658 -0.1310 -0.4833 -0.3776 -0.1952 -0.0571 -0.9267
The final concatenated vector VU.
Columns 1 through 13
0.9490 0.3080 -0.9261 0.2858 -0.0222 0.8156 -1.2365 0.4256 -0.0918 1.2658 -0.1310 -0.4833 -0.3776
Columns 14 through 16
-0.1952 -0.0571 -0.9267
I have more than 1000 vectors like 'VU'. I need to reconstruct the oroginal matrix H with vector VU given.
Some similar Matlab forum solution is given in
But could not improvise further

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 24 Jul. 2021
Bearbeitet: Jan am 24 Jul. 2021
A = rand(4) + 1i * rand(4);
A = A + A'; % Hermitian
% Convert to vector:
D = diag(A).';
L = triu(A, 1);
Lf = L(L ~= 0).';
Lv = [real(Lf); imag(Lf)];
VU = [D, Lv(:).'];
% And backwards:
n = sqrt(numel(VU));
L = triu(ones(n), 1);
L(L==1) = VU(n+1:2:n*n) + 1i * VU(n+2:2:n*n);
% Or: L(L==1) = [1, 1i] * reshape(VU(n+1:n*n), 2, [])
B = diag(VU(1:n)) + L + L';
isequal(A, B)
ans = logical
1
  1 Kommentar
Karthik Nagaraj
Karthik Nagaraj am 24 Jul. 2021
The first part of converting matrix to vector looks exactly as my function. But the code for reconstruction of the matrix back from the vector is really good. This must be one of the best answers! Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by