Jan-06-2021, 07:58 PM
(This post was last modified: Jan-06-2021, 07:59 PM by CarnariusXx.)
I wrote this :
When I not don't change code I've an error:
When I did
import numpy as np from math import pi def dft(signal): N = 1000 K = N k = 0 n = 0 wList = [] for k in range(k,K): intSum = np.complex(0,0) for n in range(n,N): real_part = np.cos(((2 * np.pi) / N) * k * n) imag_part = np.sin(((2 * np.pi) / N) * k * n) wList.append(np.complex(real_part,-imag_part)) intSum = intSum + signal * wList return intSum sigK = 3 sigPhase = 0.0 x = 0 N = 1000 signal = np.array(np.complex(0,0)) for x in range(x,N): Sample = np.complex(np.cos((2*pi/N)*x + sigPhase), 0.0) signal.append(Sample) print(dft(signal))I want that signal will be array complex of points and argument of dft function. I think is almost all but still I can't manage with multiply two complex arrays and append it.
When I not don't change code I've an error:
Error: intSum = intSum + signal * wList
ValueError: operands could not be broadcast together with shapes (2,) (3,)
When I don't put Sampleinto
signalarray I see
Error:line 29, in <module>
signal.append(Sample)
AttributeError: 'numpy.ndarray' object has no attribute 'append'
intSum should keeps signal multiply by real and imag parts (wList)When I did
np.append(signal, Sample)Output of it (print(np.append(signal,Sample))) (is one point instead one thousand