Can someone advise how I fix this loop?

조회 수: 1 (최근 30일)
DavidL88
DavidL88 2020년 6월 5일
댓글: DavidL88 2020년 6월 10일
I am using a MatLab based interface for processing EEG files collected from 59 subjects. The below code works but only for 1 file and I have 59 files I want a result from. sFiles filters the files stored in this interface and correctly returns 59 files. However, sStudy only returns a result for the first file. How do I run a loop on the below code so I can get 'n' for all 59 files? I would like to get the result 'n' for each file along with the subject name (in sFiles as SubjectName).
sFiles = bst_process('CallProcess', 'process_select_search', [], [], ...
'search', '(([name CONTAINS "resample"]))');
sStudy = bst_get('Study', sFiles.iStudy);
DataMat = in_bst_data(sStudy.Data(i).FileName);
n = numel(DataMat.F.events(3).times)

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020년 6월 5일
Hi,
That would be somewhat in this way:
for ii = 1:59
sFiles(ii).iStudy = bst_process('CallProcess', 'process_select_search', [], [], ...
'search', '(([name CONTAINS "resample"]))');
sStudy = bst_get('Study', sFiles(ii).iStudy);
DataMat = in_bst_data(sStudy.Data(ii).FileName);
n(ii) = numel(DataMat.F.events(ii).times);
end
  댓글 수: 5
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020년 6월 10일
Is that working ok, now? if so, hit accept the answer. Thx.
DavidL88
DavidL88 2020년 6월 10일
Hi Sulaymon,
That was the right approach thanks. I had to change the variables.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by