Everything up until the graph goes in to creating the lambda_Q and u_3Q matricess for a known Q matrix. The solve block is an attempt at solving the inversed problem where lambda and u are known and Q is sought.
I have managed to return results but I am not sure if it is what you are after.
As already suggested, get rid of the summation and the indexing.
You're absolutely right and it works perfectly now. I initially dismissed it as being too simple to be correct but I guess I need to brush up on my matrix multiplication rules. Thank you so much!