필터 지우기
필터 지우기

Input combination of string and number to a function which only accepts numbers?

조회 수: 1 (최근 30일)
I am using EEGLAB on Matlab and would like to cut sections of the EEG between blocks. In EEGLAB the function is pop_select which accepts numbers separated by semicolon, e.g. [0 100; 120 150; 160 170], to select e.g. the period from 0 to 100 ms, etc.
I would like to create this input as an array, input_array, which is fed directly to the function, e.g. pop_select( EEG, 'notime', input_array), since I don't know beforehand which time periods I want to select.
However, the input must be separated by semicolon, which means that input_array contains strings and cannot be converted to a number array. Is there a way to overcome this?
  댓글 수: 2
Rik
Rik 2021년 7월 15일
How exactly does that mean input_array contains strings?
I only see a 3x2 numeric array.
[0 100; 120 150; 160 170]
ans = 3×2
0 100 120 150 160 170
Martin Randau
Martin Randau 2021년 7월 15일
When constructing the array I need to insert the semicolon as a string. The function pop_select will not accept the input without semicolon separating the time intervals. So ";" is a string, so is "[" and "]" which I have to put at the end and start of the input, respectively.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 7월 15일
MATLAB uses semicolons to construct arrays. A semicolon represents the end of a row. Anything following it is placed on the next row.
You can learn more about this in Ch 4 of MATLAB Onramp.
  댓글 수: 9
Cris LaPierre
Cris LaPierre 2021년 7월 15일
Incidentally, that produces exactly the same result as this code I shared earlier:
input_array = [EEG.xmin boundaryEnd_sec(2:end); boundaryStart_sec(2:end) EEG.xmax]';
EEG = pop_select( EEG, 'notime', input_array)
Martin Randau
Martin Randau 2021년 7월 15일
Yes, sorry, I forgot to add that both solutions work! Thanks again! :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by