Loop calculation and output

1 次查看(过去 30 天)
i have 170 files of eeg recording. i want output of each file to be stored in a seperate excel file. i am not sure how to do this. pls help
My code to initiate is as below:
txtFiles = dir('*.txt') ;
l=length(txtFiles);
N = l*10 ;
Bandsheet = zeros(N,8);
PSDSheet1 =zeros(N,16);
PSDSheet2 =zeros(N,16);
PSDSheet3 =zeros(N,16);
for n=1:170
filename = ['00000460_', int2str(n), '.txt'];
x=load(filename);
figure;

采纳的回答

Yongjian Feng
Yongjian Feng 2022-2-11
You meant this:
txtFiles = dir('*.txt') ;
l=length(txtFiles);
N = l*10 ;
Bandsheet = zeros(N,8);
PSDSheet1 =zeros(N,16);
PSDSheet2 =zeros(N,16);
PSDSheet3 =zeros(N,16);
for n=1:170
filename = ['00000460_', int2str(n), '.txt'];
x=load(filename);
figure;
% then you are going to update Bandsheet, PSDSheet1, etc here?
% and you want to write them into different excel files?
fname = ['00000460_', int2str(n), '.xlsx'];
writetable(Bandsheet, fname, 'Sheet', 'Bandsheet');
writetable(PSDSheet1, fname, 'Sheet', 'PSDSheet1');
writetable(PSDSheet2, fname, 'Sheet', 'PSDSheet2');
writetable(PSDSheet3, fname, 'Sheet', 'PSDSheet3');
end
  6 个评论
Yongjian Feng
Yongjian Feng 2022-2-11
Great.
Accept the answer please then.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by