Your code is generating a syntax error for each element that is not set.
$ echo "${cluster1[0]+1}+${cluster2[0]+1}+${cluster2[0]+1}"
1+1+1
$ echo "${cluster1[1]+1}+${cluster2[1]+1}+${cluster3[1]+1}"
1+1+
It would be better to count the set elements instead of trying to calculate with a generated expression in this case:
#!/bin/bash
cluster1=(x y)
cluster2=(a b)
cluster3=(m)
for (( i = 0; i < 3; ++i )); do
is_set=( ${cluster1[i]+"1"} ${cluster2[i]+"1"} ${cluster3[i]+"1"} )
printf 'i=%d:\t%d\n' "$i" "${#is_set[@]}"
done
This creates a new array, is_set, that will contain a 1 for each array that contains an element at index i. The 1 is unimportant and could be any string. The number of elements in the is_set array (${#is_set[@]}) is then the number of set elements from the cluster arrays at that index.
Testing:
$ bash script.sh
i=0: 3
i=1: 2
i=2: 0