I give a simple example of what I want to do in Matlabs MuPad
S := matrix([[0,S_1,S_2]]);
sum(S[k]*(k < 2)* S[k] * (TRUE), k=1..3)
should be: "S_1^2 + S_2"
however I get: Error: The first argument must be of type 'Type::Arithmetical'. [sum]
I understand the error, I just don't know how to succeed. Advice appreciated. I'm looking for some kind of indicator function.