0

I have 53 xls table (ch_1, ch_2, ...) and then use them as a input for Neural Network. After that write the NN result in a new xls and 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

The problem is: when i try this programm with one, two till 9 table, the Result which i save through xlswrite are true, but when i try it with 52 table, i get a false table because for example ch_1 is overwritten whith ch_10.
Any IDEA???

Hase
  • 11
  • 3
  • What is wrong with the table? Does 'A' contain the data you are expecting? – Daniel Mar 25 '15 at 18:03
  • I found the problem. The program overwrite for example ch_1 with ch_10, but i have no solution yet! :( – Hase Mar 25 '15 at 22:35
  • Please example code which allows to reproduce this. I assume the neuronal network stuff is unrelated to the issue with the filenames. – Daniel Mar 25 '15 at 22:38

1 Answers1

0

I solved my problem. 'dir' read first ch_10 to ch_19 then ch_1. I did rename all my files and it works now correctly.I did the following to rename all files:

    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
Hase
  • 11
  • 3