EEG data, tried three different ways and end up with same subsindex error

조회 수: 3 (최근 30일)
I am writing a code that replaces values around an EEG data file where there is a 9, it changes the values (4 to the left and 7 to the right) to 5:16 for option 2 and for option 3, it would look for number 59 and replaces values around it from 58 to 63.
function OUTEEG = FormatEEGarry(EEG,option)
x= pop_loadset;
optionChoose = inputdlg('What option do you want?:', 'Option input',[1,30])
option = str2num(optionChoose{:}); %option chosen and stored
search_9 = find([x.event.epochtype]==9);
search_59 = find([x.event.epochtype]==59);
if option ==1
for k=1:size(x.event,2)
temp= x.event(k).epochtype
if [x.event(k).epochtype] ~=1;
x.event(k).epochtype =99;
end
disp([temp x.event(k).epochtype])
end
end
if option ==2
for ii= 1:size(search_9);
temp= x.event(ii).epochtype;
if (search_9(ii)+7) <= size([x.event.epochtype],2)
if (search_9(ii)-4) >= 1
ringa = search_9(ii) + [-4:7];
[x.event(ringa).epochtype]= 5:16;
end
end
disp([temp x.event(ii).epochtype])
end
end
i keep getting an error for the line
[x.event(ringa).epochtype]= 5:16;
and the error is Undefined function or variable 'ringa'.
Error using subsindex Function 'subsindex' is not defined for values of class 'struct'.
An alternative choice for option 2 that i used is as follows,
if option ==2
temp = x.event(ii).epochtype
Z = +regexprep(char(x.event.epochtype),sprintf('.{0,4}%c. {0,7}',9),char(5:16))
disp([temp x.event(k).epochtype])
end
This seems to do half the job and changes the data around 9 to 1 1 1 9 10 11 12 1 1 1. Which is not quite there yet.
I am not really sure what to do here??

채택된 답변

Walter Roberson
Walter Roberson 2015년 8월 7일
Time to use the debugger
dbstop if error
then run the code. When it stops with the error about ringa not being defined, verify that the line before is indeed
ringa = search_9(ii) + [-4:7]
and make sure that the spelling of the variable is exactly the same. Point to the variable in the line before to see its value. Use "whos" to see which variables are in the workspace.
  댓글 수: 2
Sanwal Yousaf
Sanwal Yousaf 2015년 8월 12일
Apologies for trying this so late. I just tried this and this is what i got. I changed the name of ringa to change_data;
K>> change_data = search_9(ii) + [-4:7]
change_data =
13 14 15 16 17 18 19 20 21 22 23 24
and
K>> whos Name Size Bytes Class Attributes
change_data 1x12 96 double
ii 1x1 8 double
option 1x1 8 double
optionChoose 1x1 114 cell
search_59 1x22 176 double
search_9 1x22 176 double
temp 1x1 8 double
x 1x1 40278920 struct

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

추가 답변 (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