I have solved the problem by modifying the line to;
>> s.x = s.x + K' * (s.z-s.H*s.x); %added transpose of K
This was required as my observance vector (z) was a 2X1 matrix(and so is K and hence they couldn't be multiplied). Although the calculation now works I am still wondering why it doesnt work with the original code.
Excellent resource for those of us who are new to Kalman filtering. Thank you! What if the state of my system is given by a vector rather than a scalar? Can Kalman filtering work in n dimensions? If I want to train the filter on one set of data and then apply it to another, how would I do that? What if my observations are a sum of two or more signals, plus noise? How do I "tell" the Kalman filter which of the signals I want it to estimate?