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)

 Akzeptierte Antwort

Rik
Rik am 24 Aug. 2020
Bearbeitet: Rik am 24 Aug. 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 Kommentare

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?
It isn't a string, it is a vector. What format would you like to have? Just the numbers with a comma in between?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 24 Aug. 2020

Kommentiert:

Rik
am 24 Aug. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by