You can use a for loop to build up expressions.
Something along the lines of the following, or you can rearrange it as you prefer.
I have written this presuming the superscript k matrices are the (:,:,k) entry of a d by N by K array. But if d varies for each k, as you imply, then I leave it to you to adapt the code to your circumstance.
Obj = 0
Obj = Obj + square_pos(norm(D(:,:,k)W(:,:,k) - X(:,:,k),‘fro’))
Obj = 0.5Obj + other terms