Question: Python Preliminaries: import random class Card: suit_sym = {0: 'u2663' , 1: 'u2666' , 2: 'u2665' , 3: 'u2660' } rank_sym = {0: '2' ,
Python
Preliminaries:
import random class Card: suit_sym = {0: '\u2663', 1: '\u2666', 2: '\u2665', 3: '\u2660'} rank_sym = {0: '2', 1: '3', 2: '4', 3: '5', 4: '6', 5: '7', 6: '8', 7: '9', 8: '10', 9: 'J', 10: 'Q', 11: 'K', 12: 'A'} def __init__(self, rank, suit): self.rank = rank self.suit = suit def __repr__(self): return self.rank_sym[self.rank] + self.suit_sym[self.suit] def __eq__(self, other): return self.suit == other.suit and self.rank == other.rank class Player: def __init__(self, card_list): self.card_list = card_list self.score = 0 def __repr__(self): return 'cards: ' + str(self.card_list) + ', score: ' + str(self.score) # Utility function to help with testing. Don't change this function. def build_deck(): card_list = [] for i in range(4): for j in range(13): card_list.append(Card(j, i)) return card_list # Utility function to help with testing. Don't change this function. def build_players(): player_list = [] for i in range(4): player = Player([]) player_list.append(player) return player_list 
1. Write a MATLAB code that creates a cosine signal x1A*cos(2"pi 1:N; where - the magnitude A is a random number between 0.5 and 1 the frequency f is a random number between 0.05 and 0.2 the length (or duration) of the cosine, N, is a random number between 100 and 500 2. Follow the same process as in part 1, and create another two cosine signals, namely x2 and x3. Concatenate the three signals to form one signal x [x1 x2 x3]; Make sure that x1, x2, and x3 are all row vectors. Otherwise, this is not going to work. 3. Write a MATLAB code using a while loop that splits the signal x in non-overlapping segments of length 100. Place each segment in a MATLAB cell. For each segment, s1), s12), etc, use the absolute value of the fft, i.e., abs(fft(si))), for the i-th segment, to find out where the maximum peak is located. You can use the command find for this purpose as follows w = find(abs(fft(s(i)))-=max(s(i))); This piece of code will return a vector w which contains the location where the peak is found. Remember that the absolute value of the fft will contain peaks symmetrically located around the center. Therefore, you need to keep only the first location, i.e., w(1). Using w(1), determine te frequency of the cosine in segment sti)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
