Inner matrix dimensions must agree error
3 views (last 30 days)
Show older comments
nlen=28;
a=ones(5601,nlen);
h=ones(5600,nlen);
Q=0.01;
x=ones(5600,nlen);
w1=ones(5600,nlen);
w=w1*sqrt(Q);
x_0=xlsread('D:\ieee14\faultset.xlsx',1,'A5601:AB11201');
x(1)=a*x_0+w(1);
this is my code and i keep getting this error Error using * Inner matrix dimensions must agree. Error in x(1)=a*x_0+w(1);
how to remove it? i want to do matrix multiplication
0 Comments
Answers (1)
Geoff Hayes
on 14 Apr 2017
Nana - looking at your code, a is a 5601x28 matrix and w is a 5600x28 matrix. The dimensions of x_0 are unknown (from the above code anyway). Your equation is
x(1)=a*x_0+w(1);
Since you are multiplying a with x_0, then the number of rows of x_0 must be identical to the number of columns of a. This means that x_0 must have 28 (i.e. nlen) rows. From the error message, this doesn't appear to be true. What can you tell us about the dimensions of x_0? In your code, add
size(x_0)
Also, since the number of rows of a is one more than the number of rows of w, you will not be able to add the product of a with x_0 since it will have 5601 rows and the w will have 5600.
6 Comments
Geoff Hayes
on 16 Apr 2017
Nana - I think that you need to review what it is you want your Kalman filter to do. What are the observations? What is the state vector? What are you trying to model?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!