I have the following lines of code where I find an event "41" in my cell array called Events (minimal example of this array included below) and the lines of code allow me to add 8 events labeled "411" after "41" and this is output in out1 (a result of this is shown as well). My issue is that I need to include 5 entries of "411" BEFORE "41" and I'm not sure how to do it.
How can I modify the lines below to be able to do that easily?
out1 = arrayfun( @(x,b) [x; repmat({'411'}, 8*b, 1)], Events, strcmp('41',Events), 'uni', 0 );
out1 = vertcat(out1{:});
Events = ['9991' '9991' '9991' '9991' '9991' '9991' '9992' '10' '11' '41' '42' '10' '11' '43' '44'];
out1 = ['9991' '9991' '9991' '9991' '9991' '9991' '9992' '10' '11' '41' '411' '411' '411' '411' '411' '411' '411' '411' '42' '10' '11' '43' '44'];
Thanks!