I was hoping somebody could advise me on how to achieve something with neural networks.
I used the neural network pattern recognition tool GUI to create a network for data classification.
I saved the network as net.mat
What I would like to do is, loop through files in the current work folder, which contain normalized inputs and run these through the network. Then save each ouput with same name as the input - so I can identify them at a later stage.
I'm not good coding but I suppose an attempt would be something like this:
files = dir('*.txt'); for k = 1:numel(files) output = sim(net, files(k).name) %save the output with the same name as input to E:\NNoutput end I would really appreciate any advice
No products are associated with this question.
This is the code that I created.
If there is an error, please tell me.
files = dir(fullfile(pwd,'*.txt')); for k = 1 : numel(files) %%%% reading the txt file fid01 = fopen(fullfile(pwd,files(k).name)); idx = 0; tmparray = ; tline = fgetl(fid01); while ischar(tline) idx = idx + 1; tmparray(idx,:) = str2num(tline); tline = fgetl(fid01); end fclose(fid01);
%%%% simulate net output = sim(net, tmparray);
%%%% save the output filename = strcat(regexprep(files(k).name,'.txt',''),'-output.txt'); fid02 = fopen(filename,'w'); fprintf(fid02,'%.2f\n',output'); fclose(fid02); end