我正在尝试将一些 Matlab 代码转换为 Python。我在切片时遇到问题。
Matlab代码:
demod_1_b=-1*mod_noisy*2.*sin(2*pi*Fc*t+phi);
y = filter(Hd,demod_1_b);
y2=conv(y,raised)/ConvFac;
%% till this line the length in python and Matlab are same
y2=y2(sa/2:end-(sa/2));
%%%% when i write this line in Python it gives me wrong answer it should come out as 26 but in python it gives me 33 i think i havnt converted it in a rigth way
demod_3_b=y2(sa/2:sa:end);
蟒蛇代码:
demod_1_b=-1*mod_noisy*2*sin((2*pi*Fc*t)+phi)
N=10
Fc=40
Fs=1600
d=firwin(numtaps=N,cutoff=40,nyq=Fs/2)
print(len(d))
Hd=lfilter( d, 1.0, demod_1_b)
y2=(convolve(Hd,raised))/Convfac
print(len(y2))
y2=y2[(sa/2)-1:-sa/2]
print(len(y2))
# problem starts here
demod_3_b=y2[(sa/2)-1:sa:,]
print(len(demod_3_a))
我只想问,demod_3_b=y2(sa/2:sa:end);
在 Matlab 和demod_3_v=y2[(sa/2)-1:sa:,]
Python 中是一样的吗?