How to display the loop number as a value in an array?

I have a loop that is accessing data from one array and creating another array of about 500 rows x 4 columns. I want one of those columns to have the value of the LOOP NUMBER (which is not always the same as the ROW number in the new array). disp gives me the correct value, but how can I hold that value and put it into a column?

 Respuesta aceptada

Adam Danz
Adam Danz el 30 de Jul. de 2018
Is there a problem with storing the loop variable like this in column 1?
for i = 1:100
data(i,1) = i;
end

3 comentarios

Jasmine Karim
Jasmine Karim el 30 de Jul. de 2018
Editada: Jasmine Karim el 30 de Jul. de 2018
Sorry, I should have specified the new array is a cell array.
This loop is giving me the error, "Conversion to cell from double is not possible."
Is there a way around this?
Adam Danz
Adam Danz el 30 de Jul. de 2018
Change the parentheses in data(i,1) to curly brackets and see if that solves your issues. data{i,1}
Thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Jul. de 2018

Comentada:

el 30 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by