mercredi 3 avril 2019

How to fix this syntax error in octave for if condition

Here A and B are vectors of same size. Parser throwing this error

syntax error

>>> if A[i] == B[i]

I looked at the sample code in help and other place where == is the syntax to check equality. Not sure if there is any issue in accessing the vector elements

Relevant source code looks like this

    for i = 1:m
        if A[i] == B[i]
        else
            C = C + A[i] * B[i]
        endif
    endfor

Aucun commentaire:

Enregistrer un commentaire