0
에 대해 지원되지 않는 피연산자 유형
파이썬 코드로 고민하고 있습니다. 이걸하고 싶다 equation.Python -> TypeError :^
이 내 코드 :
fs= 5000
T=np.linspace(0,2.2,fs)
n=np.arange(fs*2.2)
u=[]
for x in T:
if x < 0.2:
u.append(x * np.sin(34*np.pi*n/fs))
if (x >= 0.2 and x < 0.8):
u.append(1/x * np.log10(x+1))
if x >= 0.8 and x < 1.4:
u.append((x^2 + 1) * np.sin(12*np.pi*n/fs))
if x >= 1.4:
u.append(np.sin(20*np.pi*n/fs + x/3))
그리고 파이썬 수익률 :
File "D:/Semestr V/Podstawy Transmisji Danych/labki-ZAD3.py", line 20, in <module>
u.append((x^2 + 1) * np.sin(12*np.pi*n/fs))
TypeError: unsupported operand type(s) for ^: 'numpy.float64' and 'int'
제목 자체는 의미가 없습니다. –
문체 목적으로, if, elif, else 규칙을 논리에 사용하십시오. – APorter1031
[Python TypeError :^: 'float'및 'int'에 대해 지원되지 않는 피연산자 유형의 가능한 복제본 (https://stackoverflow.com/questions/34258537/python-typeerror-unsupported-operand-types-for- float-and-int) – kazemakase