With 2 helper functions you can easily emulate what you want:
model Test
Real[9] q;
equation
q[2] = 1.2;
q[4] = 1.4;
for i in allExcept(1:9, {2,4}) loop
q[i] = 0;
end for;
end Test;
Here are the functions you need for that:
function contains
"Check if vector v contains any element with value e"
input Integer vec[:];
input Integer e;
output Boolean result;
algorithm
result := false;
for v in vec loop
if v == e then
result := true;
break;
end if;
end for;
end contains;
function allExcept
"Return all elements of vector v which are not part of vector ex"
input Integer all[:];
input Integer ex[:];
output Integer vals[size(all, 1) - size(ex, 1)];
protected
Integer i=1;
algorithm
for v in all loop
if not contains(ex, v) then
vals[i] := v;
i := i + 1;
end if;
end for;
end allExcept;
Note that Modelica tools usually need to know the size of vectors during translation, especially here when you generate equations. Hence, the following line is required:
output Integer vals[size(all, 1) - size(ex, 1)];
It will fail when all
or ex
contain duplicate elements.
Therefore the model will not translate, if you try something like
for i in allExcept(1:3, {2, 2}) loop