Loading text files by looping through two number sequences

1 visualizzazione (ultimi 30 giorni)
I have 1800 files that I wanna loop through. They're named cut1_1 to cut90_20. The first number goes from 1 to 90 and the second number goes from 1 to 20. I understand that I have to have two loops but loading each file onto solidworks is giving me a hard time.

Risposta accettata

Walter Roberson
Walter Roberson il 15 Ago 2019
You do not need two loops. You can use a routine such as https://www.mathworks.com/matlabcentral/fileexchange/10959-sort_nat-natural-order-sort to sort the file names into numeric order.
However, using two loops should be easy enough:
for casenum = 1 : 90
for subsetnum = 1:20
filename = sprintf('cut%d_%d', casenum, subsetnum);
do something with filename
end
end

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by