matlab 如何处理缩进错误:意外缩进?

h6my8fg2  于 2023-01-31  发布在  Matlab
关注(0)|答案(1)|浏览(248)

我试图从Matlab到Python编写MSE函数,但我得到这个错误:

for i in range(len(RuleBase)):
^
IndentationError: unexpected indent

这是我的python代码:

def Mse(RuleBase,x1,x2):
temp=np.zeros(shape = (1,6))
soogeno=np.zeros(shape = (49,4))

for i in range(len(RuleBase)):
    y=crisp(m=0,M=50,fy=RuleBase[i,3],n=7) 
    temp[0]=RuleBase[i]
    temp[0,2]=y
    Soogeno[i]=temp[0,0:3]
    return(soogeno)
bejyjqdl

bejyjqdl1#

缩进在python中是严格执行的:
应运行:

def Mse(RuleBase,x1,x2):
    temp=np.zeros(shape = (1,6))
    soogeno=np.zeros(shape = (49,4))

    for i in range(len(RuleBase)):
        y=crisp(m=0,M=50,fy=RuleBase[i,3],n=7)
        temp[0]=RuleBase[i]
        temp[0,2]=y
        Soogeno[i]=temp[0,0:3]
    return(soogeno)

相关问题