Question

In: Electrical Engineering

Generate 8 × 8 random complex unitary matrix in Matlab. You can only use eig and...

Generate 8 × 8 random complex unitary matrix in Matlab. You can only use eig and randn Matlab functions. Your code can only have two lines and no semicolumns. You should generate a different random unitary matrix with each run.

Solutions

Expert Solution

MATLAB CODE

x=(randn(8)+1i*randn(8))
[X,Y]=eigs(x)

% Randn(x) willl generate 8 X 8 random matrix
% [a,b] = eigs(___) returns diagonal matrix Y containing the eigenvalues on the main diagonal,
% and matrix A whose columns are the corresponding eigenvectors

RESULTS

RUN 1

x =

Columns 1 through 4

-1.5579 + 0.7667i -1.6439 - 1.1114i -0.8407 + 0.9295i 1.3067 + 0.7609i
-2.0666 + 1.5235i 1.5815 + 0.4682i -0.3495 - 0.0904i -0.2844 + 0.2379i
-0.0726 + 0.5768i 0.2926 + 0.3226i 0.0296 - 2.6411i -0.7917 - 0.2084i
0.7591 + 0.4260i -1.1876 + 0.1000i 1.9524 - 0.4861i 0.2406 + 0.0247i
-0.0817 - 0.0429i 1.0759 + 0.3014i 0.4590 + 0.1960i -0.0946 - 0.0281i
-0.1585 - 1.2423i -1.2974 + 0.0238i -0.3993 + 0.9597i 0.7932 + 0.1404i
0.0065 - 0.5050i -0.1218 - 0.0221i -0.2254 + 1.3803i 0.9594 + 0.2376i
-1.0646 + 0.3259i 0.7408 - 0.0088i -0.2803 - 0.9415i 1.0871 - 0.6715i

Columns 5 through 8

0.6472 - 1.0450i -0.2993 - 1.0290i -1.6488 - 0.2256i -0.4667 - 0.6127i
0.6326 + 0.9658i -1.7210 + 0.2065i -0.1820 - 0.9660i -1.4358 + 2.0718i
1.9033 - 0.2198i 0.1834 + 1.3411i 0.6157 + 0.0950i -0.9777 + 0.6370i
-1.1600 + 1.4145i -0.2597 + 1.3327i -0.3767 - 0.2567i 0.6059 + 0.0749i
-0.3473 - 0.9242i -1.3548 - 1.2849i -0.6980 + 2.3101i -0.1137 + 1.1233i
-1.6951 - 0.5941i -1.1574 + 1.6184i 0.3041 + 0.1901i 0.7646 - 0.0331i
0.9194 + 1.4213i -0.7620 + 0.6616i 1.1011 - 0.1734i 0.6699 - 0.0977i
0.0215 + 1.4076i -0.2503 + 0.2273i -0.4466 - 0.0140i 0.3758 - 0.5566i

>> xy

x =

Columns 1 through 4

0.2200 + 0.5013i -1.1064 + 0.1095i 0.8198 - 0.9035i 0.1489 - 0.3237i
-1.7114 - 0.3238i 1.7906 - 1.5513i 0.0555 - 0.4959i 1.5319 - 0.9805i
-1.2058 + 0.5542i 2.1624 - 0.3551i -0.3531 + 0.3745i 0.5318 + 1.1796i
-1.7729 + 0.6424i -0.8193 + 1.3986i 1.6931 - 2.3705i -0.7597 + 0.8946i
-0.0725 + 0.1826i -0.0370 - 0.5135i 0.7111 + 0.6151i 0.3480 - 0.1429i
-1.7211 - 2.0275i 1.9630 + 1.9172i -0.6328 + 0.2795i -0.6978 - 0.5935i
0.7019 + 1.0231i -0.5403 + 0.7784i 0.3927 + 0.8189i 2.0193 + 0.2489i
-1.0055 - 3.4915i 1.7175 - 0.2465i -0.8780 + 2.0475i -1.7937 - 1.1298i

Columns 5 through 8

-0.6595 + 0.0661i -0.4717 - 1.0462i 0.9842 - 0.5474i 0.9248 - 1.3187i
0.7715 - 0.6379i -0.1142 + 0.6187i 0.9931 - 1.6510i 1.4470 - 0.4741i
-0.8203 - 0.8193i 0.3695 + 1.3050i 0.6682 + 0.8928i 0.5958 + 0.9874i
0.0179 + 0.9680i -0.6186 + 1.0235i -0.0650 - 0.5071i 2.0533 - 2.0730i
0.6545 + 0.0303i 0.8001 - 2.1154i -0.6201 - 0.3298i -1.5293 + 1.2440i
1.2577 + 1.3511i 0.4267 + 0.6817i 0.2241 + 0.1684i 0.0227 - 0.3152i
-0.9271 - 1.0864i -0.4723 + 0.0087i -0.4661 + 2.5367i 0.0953 + 1.3993i
-0.1699 + 0.2403i 0.2760 + 0.3343i -0.3321 + 2.2936i 1.6145 - 0.8799i


X =

Columns 1 through 4

-0.0970 + 0.0723i 0.1069 + 0.3899i 0.2483 + 0.0068i -0.1139 + 0.0617i
-0.0300 - 0.3435i 0.0391 + 0.0477i -0.2607 + 0.1065i -0.2313 + 0.6020i
0.2150 - 0.3870i -0.2858 - 0.0100i -0.0774 - 0.1616i -0.1924 + 0.3390i
-0.1690 - 0.0473i -0.2856 + 0.4024i -0.1595 - 0.2423i 0.0795 + 0.0911i
0.3006 + 0.1640i -0.0078 - 0.0357i -0.2191 + 0.4353i -0.3026 - 0.2437i
-0.0447 + 0.3153i -0.0932 - 0.3303i -0.6309 - 0.0243i -0.1752 - 0.4379i
0.1615 - 0.1286i -0.0562 + 0.2718i 0.2594 - 0.1030i -0.0931 - 0.0798i
-0.4733 + 0.3928i -0.3715 - 0.4162i -0.0154 + 0.1689i -0.1068 - 0.0314i

Columns 5 through 6

-0.0997 + 0.0125i -0.1404 - 0.2363i
-0.2298 + 0.0089i 0.3379 - 0.0680i
-0.1058 + 0.1386i 0.1155 + 0.4059i
-0.4902 + 0.1129i -0.4579 + 0.1455i
0.3664 + 0.0339i -0.1547 - 0.3464i
-0.0980 - 0.2261i -0.3292 + 0.0738i
0.5752 + 0.0716i -0.0201 - 0.2954i
0.1903 - 0.2918i -0.1763 - 0.1423i


Y =

Columns 1 through 4

1.5557 - 3.6093i 0 0 0
0 1.8370 + 4.2710i 0 0
0 0 3.2918 + 0.8581i 0
0 0 0 1.9327 - 1.7584i
0 0 0 0
0 0 0 0

Columns 5 through 6

0 0
0 0
0 0
0 0
-2.1825 + 2.2491i 0
0 -2.2800 - 1.4119i

>>

RUN 2

>> xy

x =

Columns 1 through 4

0.2200 + 0.5013i -1.1064 + 0.1095i 0.8198 - 0.9035i 0.1489 - 0.3237i
-1.7114 - 0.3238i 1.7906 - 1.5513i 0.0555 - 0.4959i 1.5319 - 0.9805i
-1.2058 + 0.5542i 2.1624 - 0.3551i -0.3531 + 0.3745i 0.5318 + 1.1796i
-1.7729 + 0.6424i -0.8193 + 1.3986i 1.6931 - 2.3705i -0.7597 + 0.8946i
-0.0725 + 0.1826i -0.0370 - 0.5135i 0.7111 + 0.6151i 0.3480 - 0.1429i
-1.7211 - 2.0275i 1.9630 + 1.9172i -0.6328 + 0.2795i -0.6978 - 0.5935i
0.7019 + 1.0231i -0.5403 + 0.7784i 0.3927 + 0.8189i 2.0193 + 0.2489i
-1.0055 - 3.4915i 1.7175 - 0.2465i -0.8780 + 2.0475i -1.7937 - 1.1298i

Columns 5 through 8

-0.6595 + 0.0661i -0.4717 - 1.0462i 0.9842 - 0.5474i 0.9248 - 1.3187i
0.7715 - 0.6379i -0.1142 + 0.6187i 0.9931 - 1.6510i 1.4470 - 0.4741i
-0.8203 - 0.8193i 0.3695 + 1.3050i 0.6682 + 0.8928i 0.5958 + 0.9874i
0.0179 + 0.9680i -0.6186 + 1.0235i -0.0650 - 0.5071i 2.0533 - 2.0730i
0.6545 + 0.0303i 0.8001 - 2.1154i -0.6201 - 0.3298i -1.5293 + 1.2440i
1.2577 + 1.3511i 0.4267 + 0.6817i 0.2241 + 0.1684i 0.0227 - 0.3152i
-0.9271 - 1.0864i -0.4723 + 0.0087i -0.4661 + 2.5367i 0.0953 + 1.3993i
-0.1699 + 0.2403i 0.2760 + 0.3343i -0.3321 + 2.2936i 1.6145 - 0.8799i


X =

Columns 1 through 4

-0.0970 + 0.0723i 0.1069 + 0.3899i 0.2483 + 0.0068i -0.1139 + 0.0617i
-0.0300 - 0.3435i 0.0391 + 0.0477i -0.2607 + 0.1065i -0.2313 + 0.6020i
0.2150 - 0.3870i -0.2858 - 0.0100i -0.0774 - 0.1616i -0.1924 + 0.3390i
-0.1690 - 0.0473i -0.2856 + 0.4024i -0.1595 - 0.2423i 0.0795 + 0.0911i
0.3006 + 0.1640i -0.0078 - 0.0357i -0.2191 + 0.4353i -0.3026 - 0.2437i
-0.0447 + 0.3153i -0.0932 - 0.3303i -0.6309 - 0.0243i -0.1752 - 0.4379i
0.1615 - 0.1286i -0.0562 + 0.2718i 0.2594 - 0.1030i -0.0931 - 0.0798i
-0.4733 + 0.3928i -0.3715 - 0.4162i -0.0154 + 0.1689i -0.1068 - 0.0314i

Columns 5 through 6

-0.0997 + 0.0125i -0.1404 - 0.2363i
-0.2298 + 0.0089i 0.3379 - 0.0680i
-0.1058 + 0.1386i 0.1155 + 0.4059i
-0.4902 + 0.1129i -0.4579 + 0.1455i
0.3664 + 0.0339i -0.1547 - 0.3464i
-0.0980 - 0.2261i -0.3292 + 0.0738i
0.5752 + 0.0716i -0.0201 - 0.2954i
0.1903 - 0.2918i -0.1763 - 0.1423i


Y =

Columns 1 through 4

1.5557 - 3.6093i 0 0 0
0 1.8370 + 4.2710i 0 0
0 0 3.2918 + 0.8581i 0
0 0 0 1.9327 - 1.7584i
0 0 0 0
0 0 0 0

Columns 5 through 6

0 0
0 0
0 0
0 0
-2.1825 + 2.2491i 0
0 -2.2800 - 1.4119i

>> xy

x =

Columns 1 through 4

0.1016 - 0.8396i -0.5215 - 0.5704i 1.8258 - 1.5031i 0.3618 - 0.2942i
-0.0179 - 1.6606i 0.1271 + 0.9340i 0.2043 + 0.9218i 0.8537 - 0.5048i
-0.9603 + 3.0125i 2.1130 - 1.1383i -1.1634 + 0.1632i -0.8098 - 1.9270i
1.1728 + 1.5008i 0.5413 + 1.9572i 0.1206 - 0.8147i -1.4671 + 0.5214i
-0.3653 - 0.3590i -0.6551 - 1.7632i -1.4435 + 0.4037i -0.1039 - 2.0544i
-0.4634 - 0.1149i -0.8695 - 0.3233i 0.5823 + 0.7562i -0.8229 - 0.2698i
0.1950 + 0.3589i -0.2389 + 0.8726i -0.1815 + 2.1844i 0.4250 - 0.2750i
-0.0669 - 0.0121i -1.5760 + 0.1179i 0.0420 - 0.0938i -1.8547 + 0.8451i

Columns 5 through 8

0.8586 - 2.7712i -0.8607 + 1.2064i -0.5061 - 1.0578i -1.3479 - 0.5703i
0.3064 + 0.9181i 0.2069 + 0.1973i -0.1843 + 0.1515i 1.5479 - 0.3939i
-1.1116 - 0.5193i -0.2075 - 0.7069i 0.4020 + 0.4113i -0.6166 - 1.0174i
-0.3172 - 1.2930i 0.3403 + 1.2164i 0.5392 + 0.0705i -0.6986 + 0.2502i
0.8379 - 0.0087i -0.4981 + 0.3672i -0.7336 - 1.9330i -1.4236 + 0.2521i
2.4265 + 0.2334i -1.4214 - 1.2675i -0.2684 + 0.8187i -0.1096 - 0.7715i
-0.3511 - 0.4242i -0.2708 + 0.6211i 0.8706 + 1.2618i -0.1027 + 0.9195i
1.3820 - 1.4694i 0.4397 - 1.7955i 0.3308 + 1.1673i -0.3227 + 0.8522i


X =

Columns 1 through 4

0.3540 + 0.2806i -0.0828 + 0.5477i -0.1527 - 0.0982i 0.1790 - 0.3628i
0.0032 + 0.2592i 0.0190 - 0.0142i 0.3871 + 0.0995i -0.3138 + 0.2620i
0.0738 - 0.6403i -0.0246 - 0.3344i 0.0421 + 0.0613i 0.3478 + 0.4473i
0.0724 - 0.4601i -0.0589 - 0.1153i -0.1237 - 0.6318i -0.0464 - 0.1443i
-0.0218 - 0.0959i -0.1498 + 0.3492i 0.2682 + 0.1910i 0.1370 - 0.1690i
-0.0038 + 0.2402i -0.4232 - 0.0033i 0.3787 - 0.1816i 0.0261 + 0.0159i
-0.1262 + 0.0710i 0.0643 + 0.2199i 0.1041 + 0.0158i -0.1558 + 0.4511i
-0.0875 - 0.0187i -0.4313 - 0.0373i -0.2441 - 0.1785i -0.1322 - 0.1783i

Columns 5 through 6

-0.3726 - 0.2707i 0.0662 + 0.2174i
-0.0209 + 0.2478i 0.0858 - 0.4089i
0.0878 - 0.1453i -0.4283 - 0.0469i
-0.1964 - 0.1290i 0.0337 + 0.0604i
0.3122 + 0.1829i -0.1114 - 0.1461i
0.1916 - 0.0059i -0.2345 - 0.0480i
0.3040 + 0.3231i -0.4241 + 0.1025i
0.4119 - 0.3284i 0.0533 + 0.5470i


Y =

Columns 1 through 4

-4.1242 - 2.1950i 0 0 0
0 -0.7566 - 3.1684i 0 0
0 0 -2.4909 + 1.6185i 0
0 0 0 1.9770 + 3.2012i
0 0 0 0
0 0 0 0

Columns 5 through 6

0 0
0 0
0 0
0 0
1.6168 + 1.4220i 0
0 0.3883 + 2.8270i


Related Solutions

8. In MATLAB, the colon operator can be used in two ways: creating a matrix (or...
8. In MATLAB, the colon operator can be used in two ways: creating a matrix (or array) and selecting part(s) of a matrix (or array). Explain and give examples of each. 9. For a matrix C, that has 10 rows and 12 columns: - What is the MATLAB command to select all of row 5 from it? - What 2 MATLAB commands would ask the user for an integer, N, from 1 to 10 and then create an array D...
how would you transpose a matrix in a java program if you can only use linked...
how would you transpose a matrix in a java program if you can only use linked list not 2D - arrays.
The language is MATLAB Write a function that will generate three random integers, each in the...
The language is MATLAB Write a function that will generate three random integers, each in the inclusive range from 10 to 80. It will then return a string consisting of the three integers joined together, and also a character vector consisting of the three integers joined together. For example, if the random integers are 11, 29, and 76, the string that is returned will be "112976" and the character vector that is returned will be '112976'. I'm really confused on...
IN MATLAB, Create a 8x8 magic matrix. Then use MATLAB built in function, sum, to calculate...
IN MATLAB, Create a 8x8 magic matrix. Then use MATLAB built in function, sum, to calculate the sum of each column. Use subscript notation to find the 6th element and the last element of each magic square. Find the maximum of all the elements in each magic square.
Why matrix can be multiplied by itself if and only if it is a square matrix?
Why matrix can be multiplied by itself if and only if it is a square matrix?
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this new matrix to a file called “Assignment3_Question5.dat”.
In this assignment, you implement a 2D-matrix as a vector of vectors, and only use at()...
In this assignment, you implement a 2D-matrix as a vector of vectors, and only use at() to access its elements. Write a program that multiplies a 2D matrix with a vector. If you need to see the math, follow this link: https://mathinsight.org/matrix_vector_multiplication (Links to an external site.) For simplicity, our matrix will be of size 3 x 3. Initialize the matrix as shown in to become [1.0, 2.0, 3.0] [4.0 ,5.0 ,6.0] [7.0, 8.0, 9.0] Read the three values of...
show that a 2x2 complex matrix A is nilpotent if and only if Tr(A)=0 and Tr(A^2)=0....
show that a 2x2 complex matrix A is nilpotent if and only if Tr(A)=0 and Tr(A^2)=0. give an example of a complex 2x2 matrix which is not nilpotent but whose trace is 0
Use the sine wave and scope in the Simulink library (MATLAB) to generate and observe the...
Use the sine wave and scope in the Simulink library (MATLAB) to generate and observe the following waves: a. ?1 (?) = sin ?? b. ?2 (?) = cos ?? c. ?2 (?) = 0.5 cos ?? d. ?3 (?) = cos (?? − ?) ? = 1 ???/s
Write a MATLAB function that will generate chi-square random variables with v degrees of freedom by...
Write a MATLAB function that will generate chi-square random variables with v degrees of freedom by generating v standard normal, squaring them and then adding them up. This uses the fact that is chi-square with v degrees of freedom. Generate some random variables and plot in a histogram. The degrees of freedom should be an input argument set by the user.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT