Inner matrix dimensions must agree error

3 visualizaciones (últimos 30 días)
Nana Fernandes
Nana Fernandes el 14 de Abr. de 2017
Comentada: Geoff Hayes el 16 de Abr. de 2017
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

Respuestas (1)

Geoff Hayes
Geoff Hayes el 14 de Abr. de 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 comentarios
Nana Fernandes
Nana Fernandes el 14 de Abr. de 2017
Editada: Nana Fernandes el 14 de Abr. de 2017
also
x{1} = a*x_0+w(1);
along with the changes u said above gives me the error
Cell contents assignment to a non-cell array object.
i even changed 'a' to
a=eye(28,5601);
Geoff Hayes
Geoff Hayes el 16 de Abr. de 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?

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by