我有53个xls表(ch_1,ch_2,...),然后将它们用作神经网络的输入。之后,将NN结果写入新的xls和csv。
clc
clear all
files=dir('*.xls');
for i=1:length(files(:,1))
aa=xlsread(files(i).name);
fprintf('step: %d\n', i);
datanameXls = ['channel_' num2str(i) '.xls'];
datanameCsv = ['channel_' num2str(i) '.csv'];
a17=aa(:,1);
b17=aa(:,4);
p=size(a17);
c17=zeros(144,31);
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
A= zeros(4464, 2);
A = [o, outputs'];
A(A<0)=0;
csvwrite(datanameCsv, A);
fprintf('csv is written \n');
xlswrite(datanameXls, A);
fprintf('xls is written \n');
end
问题是:当我用一个,两个到9个表尝试这个程序时,我通过xlswrite保存的结果是真的,但是当我用52表尝试它时,我得到一个假表,因为例如ch_1被覆盖ch_10。
任何IDEA ???
答案 0 :(得分:0)
我解决了我的问题。 &#39; DIR&#39;首先读ch_10到ch_19然后ch_1。我确实重命名了我的所有文件,它现在正常工作。我做了以下重命名所有文件:
clc
clear all
files = dir('*.xls');
for k=1:length(files(:,1))
oldFileName = sprintf('ch_%dMonth_1.xls',k);
newFileName = sprintf('%03d.xls',k);
movefile(oldFileName,newFileName);
end