We cannot run your code.
Check the size of all your matrices. Be certain they are appropriate to the mathematical operations you want to perform on them.
Also, consider using the bsxfun function. It may do the calculations you want to perform.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!