matrix dimension error: need some hint!
Mostrar comentarios más antiguos
Hi,
I have a vector "Xt" where Xt dimensions are 12588 X 1. From this vector I apply this code:
S=sum((abs(Xt(2:end)-Xt(1:end-1))).^2);
which result in one number where S is a 1by1.
Now my objective is to construct a vector S (Nx1) where each value in S depends on J and K -- for instance:
S=sum((abs(Xt(j:end)-Xt(k:end-1))).^2);
At first I thought of the following (I don't want J do exceed 126):
for j=2:126 k=1:125,
S=sum((abs(Xt(j:end)-Xt(1:end-k))).^2);
end;
I got this: "Error using - Matrix dimensions must agree."
Any insight at how I can correct this matrix issue?
Thank you!
Respuesta aceptada
Más respuestas (1)
Charles Martineau
el 26 de Mayo de 2012
0 votos
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!