DV_PARSECONTROLCHANS parse out a list of control channels from the input channel list. Usage: control_channels = dv_parsecontrolchans(chanlist); Input form: channel = "top_level#sub_level_1#N#ch1#...#chN#sub_level_2#..." Output form: channels(1) = "top_level:sub_level_1:ch1" channels(2) = "top_level:sub_level_1:ch2" : : M Hewitson 26-07-06 $Id: ltpdv_parse_control_chans.m,v 1.1 2008/05/11 10:38:43 hewitson Exp $
0001 function control_channels = dv_parse_control_chans(channels) 0002 0003 % DV_PARSECONTROLCHANS parse out a list of control channels from the input 0004 % channel list. 0005 % 0006 % Usage: control_channels = dv_parsecontrolchans(chanlist); 0007 % 0008 % Input form: 0009 % 0010 % channel = "top_level#sub_level_1#N#ch1#...#chN#sub_level_2#..." 0011 % 0012 % Output form: 0013 % 0014 % channels(1) = "top_level:sub_level_1:ch1" 0015 % channels(2) = "top_level:sub_level_1:ch2" 0016 % : 0017 % : 0018 % 0019 % 0020 % M Hewitson 26-07-06 0021 % 0022 % $Id: ltpdv_parse_control_chans.m,v 1.1 2008/05/11 10:38:43 hewitson Exp $ 0023 0024 0025 % control data is sampled at 1Hz for now 0026 count = 1; 0027 0028 numtoplevels = length(channels(:,1)); 0029 0030 ch = 1; 0031 control_channels = []; 0032 for top=1:numtoplevels 0033 0034 name = channels(top,:); 0035 if(length(name)>40) 0036 0037 % parse the input string 0038 % get first part as top level 0039 [toplevel, r] = strtok(name, '#'); 0040 name = r; 0041 while(length(name) > 1) 0042 0043 % get sub level 0044 [sublevel, r] = strtok(name, '#'); 0045 name = deblank(r); 0046 0047 % get the number of sub sub levels 0048 [strN, r] = strtok(name, '#'); 0049 name = deblank(r); 0050 % convert strN 0051 N = eval(strN); 0052 % now get each sub sub level making channel 0053 % names as we go and extracting data as we go 0054 for s = 1:N 0055 [subsublevel, r] = strtok(name, '#'); 0056 name = deblank(r); 0057 control_channels = strvcat(control_channels,[toplevel ':' sublevel ':' subsublevel ]); 0058 ch = ch + 1; 0059 end 0060 end 0061 end 0062 end 0063 0064 ch = ch-1; 0065 0066 0067 0068 % END 0069