import matplotlib.pyplot as plt import numpy as np from createfile import write_to_header_file N = 64 #x1 = np.geomspace(start=30, stop=110, num=N, endpoint=True, dtype=int) x1 = np.geomspace(start=7, stop=256, num=N, endpoint=True, dtype=int) x2 = np.linspace(start=30, stop=110, num=N, endpoint=True, dtype=int) #x2 = np.geomspace(start=1024, stop=48, num=N, endpoint=True, dtype=int) #x3 = np.concatenate([x1, x2]) #y = np.zeros(N) y = np.zeros(N) plt.plot(x1, y, 'o') #plt.plot(x2, y, 'o') #plt.ylim([-0.5, 1]) for item in x1: print(item) plt.show() write_to_header_file(x1, "fade_log_seq", "fade_log_seq.h") write_to_header_file(x2, "fade_lin_seq", "fade_lin_seq.h")
results = [] for n in range(len(amp_coeff)): resultpair = [] resultpair.append(amp_label[n]) data = [] y = offset + amp_coeff[n] * signal.square(2 * np.pi * 1 * t) data.append(y) resultpair.append(data) results.append(resultpair) for n in range(len(results)): # get the list containing the array data = results[n][1] # extract the array from the list and plot it with 'x' list plt.plot(t, data[0]) plt.xlabel('sample(n)') plt.ylabel('voltage(V)') plt.show() # write_to_header_file(results, "square", "pysquare.h") # write_to_source_file(results, "square", "pysquare.c", "pysquare.h") write_to_header_file(results, "squareicon", "pysquareicon.h") write_to_source_file(results, "squareicon", "pysquareicon.c", "pysquareicon.h")
amp_coeff = [900] results = [] for n in range(len(amp_coeff)): resultpair = [] resultpair.append(amp_label[n]) data = [] y = offset + amp_coeff[n] * signal.square(2 * np.pi * 1 * t, 0.95) data.append(y) resultpair.append(data) results.append(resultpair) for n in range(len(results)): # get the list containing the array data = results[n][1] # extract the array from the list and plot it with 'x' list plt.plot(t, data[0]) plt.xlabel('sample(n)') plt.ylabel('voltage(V)') plt.show() write_to_header_file(results, "unitimpulse", "pyunitimpulse.h") write_to_source_file(results, "unitimpulse", "pyunitimpulse.c", "pyunitimpulse.h")
data.append(y) resultpair.append(data) saw_results.append(resultpair) for n in range(len(saw_results)): # get the list containing the array data = saw_results[n][1] # extract the array from the list and plot it with 'x' list plt.plot(t, data[0]) plt.show() # write_to_header_file(saw_results, "saw", "pysaw.h") # write_to_source_file(saw_results, "saw", "pysaw.c", "pysaw.h") write_to_header_file(saw_results, "sawicon", "pysawicon.h") write_to_source_file(saw_results, "sawicon", "pysawicon.c", "pysawicon.h") rsaw_results = [] for n in range(len(amp_coeff)): resultpair = [] resultpair.append(amp_label[n]) data = [] y = offset + amp_coeff[n] * signal.sawtooth(2 * np.pi * 1 * t, 0) data.append(y) resultpair.append(data) rsaw_results.append(resultpair)
resultpair = [] resultpair.append(amp_label[n]) data = [] y = offset + amp_coeff[n] * np.sin(2 * np.pi * freq * x / Fs) data.append(y) resultpair.append(data) results.append(resultpair) # res = 5 # print(results[res][0]) # list containging single 'vpp' value # print(results[res][0]) # list containing data array # f = np.sin(x) for n in range(len(results)): # get the list containing the array data = results[n][1] # extract the array from the list and plot it with 'x' list plt.plot(x, data[0]) plt.xlabel('sample(n)') plt.ylabel('voltage(V)') plt.show() write_to_header_file(results, "sine", "pysine.h") write_to_source_file(results, "sine", "pysine.c", "pysine.h") # write_to_header_file(results, "sineicon", "pysineicon.h") # write_to_source_file(results, "sineicon", "pysineicon.c", "pysineicon.h")