How to run multiple iterations while increasing the index?

I'm new to Matlab and I am trying to create a for loop.
I am trying to run the second line on each index in the array of imdata. How can I write a for loop where the index continuously increases but saves each result into a csv/table?
Below is what I have so far. Thank you for your help!
imdata(2).perforder
[N, edges] = histcounts(x)

 Respuesta aceptada

Rik
Rik el 24 de Ag. de 2020
Editada: Rik el 24 de Ag. de 2020
The easiest way to do this is to standardize the bins. If you don't want that, you should probably use a cell array.
for n=1:numel(imdata)
x=imdata(n).perforder;
[N{n}, edges{n}] = histcounts(x);
end

2 comentarios

Thank you! I just figured that part out, but I am still having trouble putting the 'N' strings into a csv file. Do you know how to do that?
Rik
Rik el 24 de Ag. de 2020
It isn't a string, it is a vector. What format would you like to have? Just the numbers with a comma in between?

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.

Preguntada:

el 24 de Ag. de 2020

Comentada:

Rik
el 24 de Ag. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by