Borrar filtros
Borrar filtros

closing specific excel file

3 visualizaciones (últimos 30 días)
Roozbeh Yousefnejad
Roozbeh Yousefnejad el 30 de Mayo de 2018
Comentada: Roozbeh Yousefnejad el 30 de Mayo de 2018
Hi all, I am opening some CSV files and then choose some columns and take an average of the last data. At the same time, I separate the name of the CSV files.
Now first, I write the name of the files in the first row. Then I want to write the numbers in matrix M in the second row. But I got an error that the file is open
clc
clear
files = subdir('C:\Users\roozm\Desktop\New folder\*.csv');
for i=1:numel(files)
filename = files(i).name;
sheet = 1;
[filepath,name,ext] = fileparts(filename);
N{i,1}= name;
subset = xlsread(filename,sheet,'A:C');
subset2 = xlsread(filename,sheet,'F:G');
subset3 = xlsread(filename,sheet,'K:N');
subset_merged=[subset,subset2,subset3];
subset_tot=subset_merged([end-6:end-2],:);
M=mean(subset_tot);
end
N=N';
xlswrite('resultset',N);
Can you please advise how can I close the excel file that I have the name in it, and then write the numbers in matrix M in it?
  4 comentarios
dpb
dpb el 30 de Mayo de 2018
Use the optional Range inputs to xlswrite
Roozbeh Yousefnejad
Roozbeh Yousefnejad el 30 de Mayo de 2018
great, thanks

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by