"Subscripted assignment dimension mismatch" when using a for loop

1 Ansicht (letzte 30 Tage)
Marco
Marco am 26 Mär. 2016
Beantwortet: MHN am 26 Mär. 2016
I'm having a problem with the following iteration
for i=L:N
e(it,1) = x(i) - flipud(y(i-L+1:i,1))' * g(:,it); %Here is the error
g(:,it+1) = g(:,it) + mu * flipud(y(i-L+1:i,1)) * e(it,1);
it = it + 1;
end
When I execute the whole code I get "Subscripted assignment dimension mismatch." error in the signaled line. I have reviewed some other posts about this error, but I don't understand how can I solve it in my code. The variable 'e' is expected to be a matrix which saves a line in every iteration.
  1 Kommentar
Star Strider
Star Strider am 26 Mär. 2016
Please give the actual sizes of these in each iteration:
  • flipud(y(i-L+1:i,1))'
  • g(:,it)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

MHN
MHN am 26 Mär. 2016
There is a mismatch here:
flipud(y(i-L+1:i,1))' * g(:,it);
You have a L*1 matrix (flipud(y(i-L+1:i,1))) and you are transposing that so it would be 1*L. So, g(:,it) must be a L*1 matrix, otherwise you will get this error.

Weitere Antworten (0)

Kategorien

Mehr zu Source Control Integration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by