How to append values of a vector in a loop?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
%len = length(vector) its the length of a part of a cell array
%a = the above vector that contains string components
for i= 1:len-1
if strcmp(a(i),a(i+1))
scores(end+1)= scores(i);
end
end
I try to run the above part and it works for some of my files but for others it come up with the error:
error: scores(437): out of bound 436
I want it to append a new element (the same value as the indexed element) to the end of the scores vector if the string in the vector a is equal to the next string in the vector a
1 comentario
Rik
el 23 de Mayo de 2020
Why do you want to do it in a loop like this?
With this description of your code and data, I don't see any reason for this error. Can you share the actual variables?
Respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!