Could you please give me an explanation on this code? (could it be rewritten in analyzer Software (EEG Data analysis)?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
cd c:\matlab
clear all
close all
files = dir(fullfile('C:\matlab\newNotchICA\MAX', '*.dat'));
cd C:\matlab\newNotchICA\MAX
k=1
fid = fopen(files(k).name);
re = regexp( files(k).name,'_','split');
dataI={0};
fmt= ['%s' repmat('%f', 1,65)];
dataI= textscan(fid,fmt, 'HeaderLines',1);
dataI= cell2mat(dataI (3:64));
fclose(fid);
filesmin = dir(fullfile('C:\matlab\newNotchICA\MIN', '*.dat'));
cd C:\matlab\newNotchICA\MIN
l=k
fidmin = fopen(filesmin(l).name);
remin = regexp(filesmin(l).name,'_','split');
datamin={0};
fmtmin= ['%s' repmat('%f', 1,65)];
datamin= textscan(fidmin,fmtmin, 'HeaderLines',1);
datamin= cell2mat(datamin (3:64));
fclose(fidmin);
dif=dataI+datamin*-1
dif2=vertcat(dif, 0:61)
a=dif2
a'
b=sortrows(a')
b'
re
cd c:\matlab
Answers (1)
Walter Roberson
on 21 Dec 2015
0 votes
It finds all .dat files in C:\matlab\newNotchICA\MAX. For the first one (alphabetically), it reads the file and extracts columns 3 to 64 of all rows except the first one. It also looks in C:\matlab\newNotchICA\MIN and finds all the .dat files there. For the first one (alphabetically), it reads the file and extracts column 3 to 64 of all rows except the first one. It subtracts the matrix of the second set of values from the matrix of the first set of values. Underneath that it puts 0 through 61 and sorts the result by columns (which it does by making the columns into rows, sorting the rows, and making the result back into columns). It displays various of the results along the way.
The indentation of the code suggests that at some point the code looped through all of the files in the MAX directory and probably read the corresponding file of the MIN directory to do the subtraction. However, logically it should try to test that it reads the correct corresponding file in the MIN directory and it does not do that test.
1 Comment
Platon Braun
on 21 Dec 2015
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!