How to exact first number of values from a variable with changed length in a loop

1 view (last 30 days)
Hi,
I have a data with three dimensions, the length of third dimension varies. Most of them are 29, but three of them are more than 29.
I want to keep exacting first 29 vectors from this matric, but I have no idea how to achieve it in the loop.
My code is like this:
The epoch_num is the variable with changing length (29 or more than 29) frag_eegs is the variable I need and store my new datasets.
% put your data into these segments
for epoch_num=1:size(EEG.data,3)
frag_eegs(:,1,epoch_num)=eeg_data(1:seg_length,epoch_num);
for n=2:num_seg
frag_eegs(:,n,epoch_num)=eeg_data(seg_length*(n-1):((seg_length*n)-1),epoch_num);
end
end
Hope I explain clearly. Thank you!

Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!