Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

the following 2D complex vectors: Construct matrix A that has five columns and a

ID: 3675124 • Letter: T

Question

the following 2D complex vectors: Construct matrix A that has five columns and as many rows as the number of vectors. The first column should be the number of the vector (1, 2, 3 ... etc). I he second and third columns correspond to the real and imaginary components of each row (as shown in the above table), while magnitude and angle (in degrees) of each column, Extract the data for the vector with the max. angle into a vector named vcc 1, Extract the angle of the vector with the max. magnitude into a variable named var_1, Construct matrix B that is the same as A(: , 2:5), hut has four extra rows, for the maximum, minimum, average, and standard deviation ot the data in A, respectively, Sort matrix B, in a descending order, according to the magnitude of the vectors and store the result in matrix C.

Explanation / Answer

tested in python 2.7. store your data in test.txt in the below foramt:

1 5 2
2 4 4
3 6 0
4 2 7
5 1 5
6 3 6
7 0 3
8 7 1

############### CODE ####################

import math

input = open("test.txt").read().split(' ')
A = []
for line in input:
   A.append(line.split(' '))

del A[len(A)-1]
for i in range(0, len(A)):
   print i
   A[i][3] = abs(complex(int(A[i][1]),int(A[i][2])))
   A[i][4] = math.atan2(int(A[i][2]), int(A[i][1]))


max = -1.0
vec_1 = []
for i in range(0, len(A)):
   if A[i][4] > max:
       vec_1 = A[i]
       max = A[i][4]
print vec_1

var_1 = 0
max = 0.0
for i in range(0, len(A)):
   if A[i][3] > max:
       var_1 = A[i][4]
       max = A[i][3]
print var_1

#part 4: Maximum and minimum of what ??#  
print A
B = []
for i in range(0, len(A)):
   B.append(A[i][1:])
print B