我有一个程序,我整个周末一直在工作,它包含正确的输出,但它输出一个不可调用的列表,我需要能够从中构建一个图。如何修改列表以使其可调用?
import numpy as np
#import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
np.set_printoptions(threshold=np.nan)
#04-01 Convolution
def conv395(x,h):
#Function to convolve x input signal and h impulse response
M = len(h)-1
L = len(x)
Ly = M+L
LOL = []
def ConV(x,h,n):
y = (h[m]*x[(n-1)-m])
return (y)
for n in range(0,Ly+1):
mx = n-L+1
if mx < 1:
n = n+1
#print("SPACE")
Y1 = 0
if n <= M+1:
L1 = []
for m in range(n):
#print(n)
y = ConV(x,h,n)
Y1 = y + Y1
L1.append(Y1)
LOL.append(str(L1))
#print Y,
###LOL = np.int32(LOL)
if n > M+1:
#print("Space")
L2 = []
N = n-1
n = M+1
Y2 = 0
for m in range(n):
y2 = h[m]*x[(N-m)]
Y2 = Y2 + y2
L2.append(Y2)
LOL.append(str(L2))
if mx > 1:
#print("space")
L3 = []
if n > M+1:
Y3 = 0
for m in range(n-L,M+1):
y3 = h[m]*x[m-(n-L)]
Y3 = Y3 + y3
L3.append(Y3)
LOL.append(str(L3))
return(LOL)
h = [1,2,-1,1]
x = [1,1,2,1,2,2,1,1]
Y = conv395(x,h)
print(callable(Y))
OUTPUT显示列表不可调用,输出看起来像这样[&#39; [1]&#39;,&#39; [3]&#39;,&#39; [ 3]&#39;,&#39; [5]&#39;,&#39; [3]&#39;,&#39; [7]&#39;,&#39; [4] &#39;,&#39; [3]&#39;,&#39; [3]&#39;,&#39; [0]&#39;,&#39; [1]&# 39] 我已经尝试过在互联网上找到的各种形式的转换,它不会让步。建议?