How to use writetable command in a for loop
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
while using writetable command in a for loop i'm able to save the text file only for the last iteration value. Hoe can i save all the text files using this writetable command?
Risposte (2)
Taha
il 11 Gen 2017
for m=1:10
test = [m:m+20];
T=table(test);
writetable(T,['test' num2str(m) '.txt'],'Delimiter','\t');
end
here is the solution! this code generates text files with the names: test1.txt, test2.txt.... using the for loop in MATLAB
3 Commenti
Dyuman Joshi
il 28 Ago 2023
Modificato: Dyuman Joshi
il 28 Ago 2023
If your error still persists, ask a new question specifying the problem/error you are facing.
Voss
il 28 Ago 2023
@Ellen Berry: For writing an Excel file (e.g., .xlsx), omit the 'Delimiter','\t' arguments. Delimiter is for text files only.
for m=1:10
test = [m:m+20];
T=table(test);
writetable(T,['test' num2str(m) '.xlsx']);
end
Vedere anche
Categorie
Scopri di più su Text Files 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!