If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
For example, you aren't telling us what Ya, va, V, etc. are Plus you are not giving us the full error message (ALL the red text) so we don't know what line the error occurs on.
Before the loop, have this
whos A
whos X
whos B
whos Z
But X(k-1,:).' is a row vector transposed so that it's now a column vector. But A is a 2-D matrix, so you're doing a matrix multiply, not an element-by-element multiply, So if A is rows x columns, then X(k-1,:).' better be columns x 1 or else it won't work as a matrix multiply. Did you intens an element-by-element multiply? If so use .* rather than *