First Part:
load ecg_data_file
Read the y axis data (mV) as another column data & store in new variable, say ecg_data. The time vector (x data in ms) is generally linearly spaced, so you can consider the same as indexing. If your time scale unit is second, consider 2 spacing, otherwise 20 spacing for ms time unit.
Suppose the time scale in seconds
ecg_data=data(:,2);
len=length(ecg_data)/2; % Considering length of ecg_data as even number
ecg_segment=mat2cell(data,2*ones(1,len),1);
The ecg_segment as follows
ecg_segment=
...×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
.......
Here individual cell elements represent segment of the signal. Aferwards you can use the cell elements for further processing or save the data also.
Think: You may consider the 3 dimensional cell array to store the segment of the ecg in multiple planes based on signal number, which is quite easy to handle on Matlab processing. But in case of save in excel or otherways you have to decide.
Second Part:
There the multiple threads to call the multiple files/mat files/text/images. You can replicate the same just by changing the the file format extention name and local path of the files.