Filter löschen
Filter löschen

closing specific excel file

3 Ansichten (letzte 30 Tage)
Roozbeh Yousefnejad
Roozbeh Yousefnejad am 30 Mai 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 Kommentare
dpb
dpb am 30 Mai 2018
Use the optional Range inputs to xlswrite
Roozbeh Yousefnejad
Roozbeh Yousefnejad am 30 Mai 2018
great, thanks

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by