Clear Filters
Clear Filters

closing specific excel file

3 views (last 30 days)
Roozbeh Yousefnejad
Roozbeh Yousefnejad on 30 May 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 Comments
dpb
dpb on 30 May 2018
Use the optional Range inputs to xlswrite

Sign in to comment.

Answers (0)

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!