lundi 30 octobre 2017

Why do I get undefined variable in an if statement?

I get an error for undefined function or variable in the if statement (last line before last end), when I have already assigned the equalities.

l_min = nan(372,1);
A = randn(372,3);
B= randn(372,3);
for t=1:372
    min_ct = min( A(t,:));
      if min_ct == A(t,1);
        l = B(t,1);
        if min_ct == A(t,2);
            l = B(t,2);
        elseif min_ct == A(t,3);
            l = B(t,3);
        end
    end
    l_min(t) = l;
end

Could anyone help with this one?

Aucun commentaire:

Enregistrer un commentaire