Effacer les filtres
Effacer les filtres

export data of a loop in different excel files

4 vues (au cours des 30 derniers jours)
Homayoon
Homayoon le 27 Août 2015
Commenté : Sham Babu le 26 Déc 2017
Hello all-- Well it seems i face with a new problem. :-(
How can I export the data corresponding to each filenumber in my code to a different excel file?
for k = 1:10
filename = sprintf('%d.txt',k);
A = load(filename);
% doing some calculations
import output as k.xlsx
end
Well my desired outputs are 10 excel files whose names are 1.xlsx,2.xlsx and etc. Thank you so much

Réponse acceptée

Stephen23
Stephen23 le 27 Août 2015
Modifié(e) : Stephen23 le 27 Août 2015
Try reading the documentation for xlswrite, and thinking about how you could adapt the code that I gave you earlier:
for k = 1:10
...
newfilename = sprintf('%d.xls',k);
xlswrite(newfilename,output)
end
Note that there are many options for xlswrite, so please read the documentation carefully.
  2 commentaires
Homayoon
Homayoon le 31 Août 2015
Dear Stephen,
I got it right just after posted the question. That is why i have not checked your answer until now. Anyway I do appreciate your concern to teach online users.
Sham Babu
Sham Babu le 26 Déc 2017
Hi, What would be the right code?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by