Why do I get: "Error using vertcat Dimensions of matrices being concatenated are not consistent."
Mostrar comentarios más antiguos
I have a vector, which should be splitted at certain points (if condition). The parts of the vector should emerge as column in a matrix. In a for-loop I want to establish the new matrix step by step. I have made some preallocation, but I still get an error message. Can someone help me? Here is my code:
Entire = zeros (d,e); %preallocation
for b = 1: lengthRS
if trigger (b,1) ==1 && trigger (b+1) == 1; %condition for splitting
single = ERGsignal(b:b+d,1); %make single part of vector (ERGsignal)
Entire = [Entire; single]; %Building up Matrix
end
end
1 comentario
Respuesta aceptada
Más respuestas (1)
James Tursa
el 1 de Abr. de 2015
Editada: James Tursa
el 1 de Abr. de 2015
1 voto
Entire has e columns
single has 1 column
So unless e == 1, they won't match and hence the error. That being said, it looks like maybe you intended to build up Entire by columns instead of rows. If so, use a comma instead of a semi-colon when attaching "single" (and adjust the size of Entire accordingly).
"single" is an extremely poor choice for a variable name btw since it matches a MATLAB class name. I would advise choosing a different name for this variable.
1 comentario
Sarah
el 2 de Abr. de 2015
Categorías
Más información sobre Logical 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!