Sequence of adding numbers
Mostrar comentarios más antiguos
Hi i have like this question. Lets say i have this code : for i=1:4 C=2+i; end
this gives me this answer: C=3, C=4,C=5,C=6
BUT I want like this answer: C1=3, C2=4, C3=5, C4=6, which is with numbers after letter C. Can anyone help please...thanks :)
1 comentario
Geoff Hayes
el 11 de Jun. de 2014
Editada: Geoff Hayes
el 11 de Jun. de 2014
This isn't all that different from your previous question http://www.mathworks.com/matlabcentral/answers/131244-string-value-and-sequently-representation….
Respuesta aceptada
Más respuestas (1)
It might better if you put all your results in one array. Perhaps like this:
ii = 1:4;
C = NaN*ones(size(ii));
for idx = ii
C(idx) = 2 + idx;
end
Without a loop:
C = 1:4;
C = C + 2;
1 comentario
Akmyrat
el 11 de Jun. de 2014
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!