Copy text file into different array depending on character in the first cell
이전 댓글 표시
I have a text file with different information in each line:
- the first 9 lines represent the experiment, date, condition and name of the subject.
- The line 10 contain the header of behavioural data
- the others contain the behavioural data which always start with the name of the subject, then eye mouvement data
- which are separated in 'all saccades' which always start with 'All Saccades' and microsaccades which start with 'microsaccades'.
I would like to create 3 arrays :
- one with only behavioural data
- one with All Saccades data
- one with micro Saccades data.
The dimension of these array will contain the same amount of lines but different number of columns.
I'm new in Matlab, and i'm not able to find the correct code.
I inser the text file and the code I made.
Thanks for your help
Alice
clc
clear
close
% Fichier à ouvrir
[filename, file_path] = uigetfile(['C:\Brandy\Pilot\*.txt'],'Choose MATLAB File to Process');
fid = fopen([file_path filename],'rt');
if fid < 0
fprintf('error opening file\n');
return;
end
%lecture du fichier
line_number = 1;
oneline{line_number} = fgetl(fid);
while ischar(oneline{line_number})
line_number = line_number + 1;
oneline{line_number} = fgetl(fid);
end
fclose(fid);
%Séparation des lignes
Title_1 = oneline{2};
Title_2 = oneline{3};
Date = oneline{4};
Time = oneline{5};
Condition = oneline{7};
SubjName = oneline{8};
Label = oneline{10};
Labels = strsplit(Label,';');
for i=1:line_number
Lines{i}=char(oneline{i});
end
j=line_number-10;
for ii = 1:j
k=ii+10;
[Index{ii},~,~,n] = sscanf(Lines{k},"%s");
end
Index_1=Index';
Data = regexp(Index_1, ';', 'split');
%Formation d'un nouveau tableau
contents{1} = Labels;
for m=1:4336
if ischar(Data{m,1}{17})==1
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Neural Simulation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!