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)

 Réponse acceptée

Rik
Rik le 24 Août 2020
Modifié(e) : Rik le 24 Août 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 commentaires

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 le 24 Août 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Question posée :

le 24 Août 2020

Commenté :

Rik
le 24 Août 2020

Community Treasure Hunt

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

Start Hunting!

Translated by