Search code examples
pythonarraysmatlabfuzzy-logicmse

How can I deal with Indentation Error: unexpected indent?


I am trying to Write the MSE function from Matlab to Python but I am getting this error:

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

This is my python code:

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)

Solution

  • Indentation is strictly enforced in python:

    this should run:

    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)