"Each ### is a patient and each of the roman numerals is a separate ECG channel. Each of the leads has hundreds of rows of data that need to have several pre-processing and filtering steps applied to them. There are a few steps that do calculation on all signals at once (ie the same row on all four channels)."
Well, now we're finally beginning to get somewhere...still much to be clarified, but this at least gives a place from which to start.
First of all, it is trivial as Stephen has pointed out to open a file for any given patient number; simply
pn=input('Which patient, please? ','s');
srchstr=sprintf('%s*',pn);
d=dir([srchstr '.csv']);
will return the list of all .csv files for the patient which you can then process sequentially by iterating over the directory structure, d.
If you need a given channel, add that to the wildcard pattern; you're fortunate in having created (or someone did for you) a pretty usable naming convention here.
chnls={'I','II','III','IV'};
[ich,ok]=listdlg('PromptString','Select Channel', ...
'SelectionMode','single', ...
'ListString',chnls);
if ok
srchstr=strcat(srchstr,chnls(ich));
end
d=dir([srchstr '.csv']);
also illustrating another user interactive tool that may make usage simpler for you.
Given your description of the file structure, one very likely way you might approach it would be, as Steven suggested, the table. As a trivial example, I built a sample record...
ts=cellstr(datestr(now));
chnl={'C001'};
ecg=randn(1,480);
t=table(datetime(ts), ...
categorical(chnl), ...
ecg, ...
'VariableNames',{'Time','Chnl','ECG'})
t =
Time Chnl ECG
____________________ ____ ______________
06-May-2017 09:25:24 C001 [1x480 double]
and VOILA! you've got a database. Patient ID can be incorporated, too, of course, as well as any other corollary info required. Then grouping variables can be used to select desired characteristics from the table by patient, time, whatever...
What we still don't know now is how much of these data are to be processed concurrently, but there surely are very powerful ways to organize the data to do whatever it is that is required without needing named variables(*) to do so.
The above is just one of many alternatives; which would work best will depend on the remaining details of what actually is to be done with the data as far as the agglomeration of what is needed in a single data structure at any one time.
(*) NB: A "named variable" is NOT in any way, shape or form the same as using a variably-named structure fieldname or as the variable name in a table. The former is essentially impossible to deal with in a generic fashion with any code of any complexity whatever; the latter are, essentially, trivial to use in Matlab.
Best Answer