Import and export excel files

Hello everyone,
I am trying to collect data of column "C" from each excel file and export the data into an excel file using for loop function.
When I open up the exported file "Load_of_samples", All data are the same as the column of the "first" excel file. (column A is the data from the first excel file, and the rest of columns (B~D) are the same as column A.
I am wondering what I did wrong.
Thank you.
XLfile = dir('*.csv');
number_of_files = length(XLfile);
OutputFileName = 'Load_of_samples';
for i = 1:number_of_files
filename = XLfile(i).name;
for i = 1:number_of_files
A(:,i) = xlsread(filename,1,'C:C');
end
xlswrite(OutputFileName,A);
end

Respuestas (1)

madhan ravi
madhan ravi el 29 de Dic. de 2018

0 votos

4 comentarios

Cheeesepondue
Cheeesepondue el 29 de Dic. de 2018
Thank you for you answer. Is there any way I can modify my functions slightly to get the desirable results, instead of following through the link?
Walter Roberson
Walter Roberson el 29 de Dic. de 2018
remove the inner for loop just leaving the assignment to A(1,i)
madhan ravi
madhan ravi el 29 de Dic. de 2018
Thank you sir Walter :-)
Cheeesepondue
Cheeesepondue el 29 de Dic. de 2018
@Water Roberson The problem was the length of rows was different for each excel files.. So now I need to work on that.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 29 de Dic. de 2018

Editada:

el 29 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by