matlab之用m脚本自动完成检查变量命名规范

文章目录

  • matlab之用m脚本自动完成检查变量命名规范
    • 0.前言
    • 1.需求分析
      • 1.1完成变量的拆分
      • 1.2对每大块拆成的小块判断
      • 1.3第二大块的要注意顺序
    • 2.程序实现

0.前言

接到这个任务好久了,由于需求一直在变,导致我无法冻结,目前算是一个比较稳定的版本,由于涉及到公司机密问题,我只能提几点对技术提高有帮助的需求,具体如下!

1.需求分析

以KtTqDmd_VehSpdSign_flg为例

1.1完成变量的拆分

第一点:拆成三大块:KtTqDmd和VehSpdSOCSign和flg
第二点:每一个大块要根据大写拆分或者其他特殊需求拆分
如下第一大块:要拆成Kt;Tq;Dmd
第二大块:Veh;Spd:SOC;Sign
第三大块:Flg

1.2对每大块拆成的小块判断

实现方法:根据大写拆分

1.3第二大块的要注意顺序

即:第二大块:Veh;Spd:SOC;Sign这四个属于4大类的话,要注意先后顺序
如:Veh属于MeanEnvironmentDevice;Spd属于ActionPhysicalType;等要注意顺序,MED一定要排在ActionPhysicalType的前面
实现方法:根据前后游标来判断(利用m语言的键值对,利用排序看是否顺序改变来判断)

2.程序实现

代码如下:

clear;
clc;
disp('程序正在运行....');
%%
% Total_variable_list 可更改提取的文件名和对应的sheet已经范围
file_name_str = './变量命名规范查询表.xlsx';
need_write_sheet = '变量表'; % pay attention names ,english name is ok
xlrange = 'A:A';
[~,Total_variable_list] = xlsread(file_name_str,need_write_sheet,xlrange);  % the first thing is data,the second is text
Total_variable_list(1)= []; % get rid of D1,the rest of type is cell
% Total_variable_list={'KtTqDmd_VehSpdSign_flg'}; % 方便调试,先提前写好% Type_identifier_list
Type_identifier_sheet = '类型标识符'; % pay attention names ,english name is ok
xlrange = 'A:A';
[~,Type_identifier_list] = xlsread(file_name_str,Type_identifier_sheet,xlrange);  % the first thing is data,the second is text
Type_identifier_list(1)= []; % get rid of D1,the rest of type is cell
% Type_identifier_list = {'C','K','V','M'}; % 方便调试,先提前写好% Type_of_data_list
Type_of_data_sheet = '数据类型'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,Type_of_data_list] = xlsread(file_name_str,Type_of_data_sheet,xlrange);  % the first thing is data,the second is text
Type_of_data_list(1)= []; % get rid of D1,the rest of type is cell
% Type_of_data_list = {'m','d','t','u8','s8','u16','s16','u32','i32','b','f'};% 方便调试,先提前写好% Extended_description_list
Extended_description_sheet = '扩展说明'; % pay attention names ,english name is ok
xlrange = 'A:A';
[~,Extended_description_list] = xlsread(file_name_str,Extended_description_sheet,xlrange);  % the first thing is data,the second is text
Extended_description_list(1)= []; % get rid of D1,the rest of type is cell
% Extended_description_list= {'1X','1Y','2X','2Y','2Z'};% 方便调试,先提前写好% unit_type_list
unit_type_sheet = '单位类型'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,unit_type_list] = xlsread(file_name_str,unit_type_sheet,xlrange);  % the first thing is data,the second is text
unit_type_list(1)= []; % get rid of D1,the rest of type is cell
% unit_type_list = {'rpm','Nm','Pct','enum','Kph','deg','V','A','s','ms','w','kw','m','km','flg','Nmps','inc','dec','lim','NULL'};% ActionPhysicalType_list
ActionPhysicalType_sheet = 'ActionPhysicalType'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,ActionPhysicalType_list] = xlsread(file_name_str,ActionPhysicalType_sheet,xlrange);  % the first thing is data,the second is text
ActionPhysicalType_list(1)= []; % get rid of D1,the rest of type is cell
% ActionPhysicalType_list = {'Abrt', 'Absptn', 'Abstrn', 'Accl',   'Acpt',   'Acs',    'Accmd',  'Ack',    'Acq',    'Actn',   'Actvn',  'Actv',   'Acttn',  'Add',    'Adh',    'Adj',    'Adjmt',  'Adsptn', 'Agi',    'Aid',    'Allot',  'Amnt',   'Ang',    'Ajerk',  'Apply',  'Arbn',   'Ar', 'Arm',    'Asstn',  'Authn',  'Aux',    'Bkp',    'Blink',  'Blstr',  'Bnce',   'Bdr',    'Brkg',   'Brn',    'BMEP',   'Brkpt',  'Bucd',   'Brng',   'Byp',    'Calc',   'Calcn',  'Cal',    'Call',   'Cncl',   'Cp', 'Chg',    'Chrg',   'Chk',    'CS', 'Chirp',  'Circum', 'Clsf',   'Cln',    'Clng',   'Clr',    'Clima',  'Cls',    'Coast',  'Coff',   'ColdStrt',   'Cllsn',  'Cmb',    'Cmng',   'Cmd',    'Cmm',    'Cmt',    'Comp',   'Cmptmt', 'Cmp',    'Conc',   'Cdsn',   'Cdng',   'Cfm',    'Cstn',   'Cnsm',   'Cns',    'Ctrl',   'Cnvc',   'Cnvn',   'Coolg',  'CD', 'Coor',   'Coorn',  'Copy',   'Corrn',  'Cnt',    'Coupl',  'Covrg',  'Crk',    'Crash',  'Crawl',  'Crp',    'Crs',    'I',  'Cut',    'Dampg',  'Day',    'Dctvt',  'Dctvn',  'Deb',    'Decel',  'Defrst', 'Defu',   'Deg',    'Dly',    'Drtv',   'Kd', 'Tv', 'Dep',    'Desptn', 'Dtcn',   'Dtrt',   'Detmn',  'Dvt',    'Diag',   'Diam',   'Diffp',  'Dffsn',  'Dgt',    'Disb',   'Disa',   'Disarm', 'Dcha',   'Dcnct',  'Disczn', 'Dst',    'Dstb',   'Dthr',   'Div',    'Dos',    'Drft',   'Drng',   'Drift',  'Drvaw',  'Drvg',   'Drp',    'Dropspd',    'Durn',   'Duty',   'Ducyc',  'Dwl',    'Edit',   'Eff',    'Ela',    'Emsvty', 'Emuln',  'Ena',    'Enag',   'Enc',    'Egy',    'Engmt',  'Enhmt',  'Enchmt', 'Entry',  'Erase',  'Err',    'Esti',   'Evln',   'Evpn',   'Excd',   'Exh',    'Exct',   'Exclsn', 'Exit',   'Exp',    'Exp',    'Expn',   'Exprt',  'Extn',   'Extrpn', 'Fac',    'Fade',   'Fall',   'Fillg',  'Fns',    'Fixa',   'Flsg',   'Flow',   'Fluc',   'Flux',   'FM', 'Fold',   'Folw',   'F',  'Frq',    'Fric',   'Fid',    'Fusn',   'Gain',   'Gentn',  'Get',    'Glw',    'Grdt',   'Grip',   'Hdlg',   'Heal','Heat',  'Heatg',  'Htc',    'Hgt',    'Hbrnt',  'Hold',   'Hr', 'Hum',    'Idn',    'Illmn',  'Img',    'Imobn',  'Impct',  'Z',  'Imprt',  'Iacv',   'Incln',  'Incl',   'Inct',   'Idx',    'Indcd',  'IMEP',   'Indcn',  'L',  'Inertia',    'Inhb',   'Inhbn',  'Initlzt',    'Inj',    'Insert', 'Insrtn', 'Insp',   'Ki', 'Tn', 'Itgr',   'Inten',  'Intrpn', 'Intrpt', 'Intv',   'Invld',  'Ivt',    'Jam',    'Jmp',    'Keep',   'Kd', 'Knk',    'Lmbd',   'Laun',   'Lyt',    'Lrn',    'Lrng',   'Lvng',   'Len',    'Lvl',    'Lvlg',   'Lighter',    'Ltg',    'Limt',   'Lnrzn',  'Lnk',    'List',   'Load',   'Ldng',   'Lct',    'Lock',   'Lockg',  'Lubt',   'Mng',    'Mpg',    'Mask',   'M',  'Masg',   'Meas',   'Milg',   'Ms', 'Mins',   'Misf',   'Misfg',  'Mtgtn',  'Modcn',  'Modln',  'Mom',    'Mon',    'Mth',    'Mtn',    'Mntg',   'Mov',    'Movg',   'Notif',  'Nr', 'Obs',    'Ohm',    'Oper',   'Optmzn', 'Orntn',  'Osc',    'Oscn',   'Ovrhtg', 'Ovrd',   'Ovtk',   'Oxd',    'Park',   'Prkg',   'Part',   'Pass',   'Passd',  'Pctg',   'Pfmnc',  'Pen',    'Polling',    'Posn',   'Posng',  'Pwr',    'Prepn',  'Prep',   'Pres',   'P',  'Prevn',  'Procsng',    'Prog',   'Progm',  'Progs',  'Kp', 'Protn',  'Pull',   'Purg',   'Push',   'Put',    'PWM',    'Quisc',  'Qut',    'Rad',    'Rd', 'Rng',    'Rate',   'Ratng',  'Rat',    'Reactn', 'Reacvn', 'Read',   'Readg',  'Rbd',    'Recall', 'Rciv',   'Rcpt',   'Recirc', 'Rec',    'Rcv',    'Recup',  'Redn',   'Rflctg', 'Refi',   'Rflx',   'Refrsh', 'Refu',   'Rgn',    'Rgln',   'Reinf',  'Rejct',  'Rels',   'Rlvc',   'Rmvl',   'Rep',    'Repn',   'Repl',   'Replm',  'Rpt',    'Req',    'Rqur',   'Rst',    'R',  'Resp',   'Rstrt',  'Restore',    'Restrnt',    'Resu',   'Rtd',    'Rvsg',   'Rvis',   'Rev',    'Rho',    'Rcrltn', 'Ride',   'Rise',   'Risg',   'Roll',   'Rollg',  'Rollovr',    'Rot',    'Roughns',    'Run',    'Runng',  'RT', 'Sfty',   'Sale',   'Smp',    'Satn',   'Save',   'Sca',    'Scan','Scav',  'Seatg',  'Sec',    'Snd',    'Sen',    'Sep',    'Set',    'Setg',   'Shd',    'Shift',  'Shdwn',  'Shup',   'Shiftg', 'Shong',  'Shtdn',  'Shto',   'Sim',    'Simn',   'Sitn',   'Sleep',  'Sldg',   'Slip',   'Slop',   'Smotng', 'Spk',    'Spd',    'Spl',    'Spt',    'Sq', 'Staby',  'Stabn',  'Stallg', 'Stamp',  'Stand',  'Stdn',   'Strt',   'Strtg',  'St', 'Sof',    'Soh',    'Sts',    'Stfn',   'Stop',   'Store',  'Strike', 'Stk',    'Sub',    'Scs',    'Suctn',  'Sppl',   'Sply',   'Spprt',  'Supp',   'Surge',  'Suspc',  'Swp',    'Sym',    'Syncn',  'Sync',   'Synt',   'Task',   'Tau',    'Telltl', 'T',  'Term',   'Test',   'Thrmls', 'Tgtnss', 'Ti', 'Tc', 'Td', 'Tout',   'Tog',    'Tq', 'Tors',   'Tw', 'Trac',   'Trf',    'Trfon',  'Tran',   'Trans',  'Trnsp',  'Trap',   'Trvl',   'Treat',  'Trig',   'Trim',   'Trip',   'Tumb',   'Tun',    'Ukwn',   'Unlck',  'Upd',    'Upw',    'Usg',    'Use',    'Valt',   'Vld',    'Vldt',   'Val',    'V',  'Ventn',  'Vibrn',  'Vcos',   'U',  'Vol',    'Wait',   'Wake',   'Wrmp',   'Warn',   'Wshng',  'Wkn',    'Weakng', 'Wght',   'Wtng',   'Wipg',   'Wish',   'Wrk',    'Wr', 'Yaw',    'Yr'};% ConditionQualifier_list
ConditionQualifier_sheet = 'ConditionQualifier'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,ConditionQualifier_list] = xlsread(file_name_str,ConditionQualifier_sheet,xlrange);  % the first thing is data,the second is text
ConditionQualifier_list(1)= []; % get rid of D1,the rest of type is cell% ConditionQualifier_list = {'Abd', 'Abno',   'Abs',    'Acc',    'Accumd', 'Acst',   'Act',    'Adptv',  'Addl',   'Addv',   'Adr',    'Adv',    'Ajar',   'All',    'Allwd',  'Alpha',  'Altv',   'Alti',   'Amp',    'An', 'Agr',    'Arbd',   'Ary',    'Assid',  'Async',  'Attn',   'Aud',    'Auto',   'Avl',    'Avg',    'B1', 'B4', 'Back',   'Backlt', 'Backkw', 'Bad',    'Bal',    'Brm',    'Bas',    'Basc',   'Beta',   'Bgft',   'Bny',    'Bli',    'Blkd',   'Bool',   'Boost',  'Boot',   'Bndls',  'Break',  'Brt',    'Bkn',    'Byte',   'Calcd',  'Cncld',  'Cpby',   'Cgrd',   'Cen',    'Chartc', 'Ckd',    'China',  'Circuml',    'Clmpd',  'Clrd',   'Clsd',   'CL', 'Cot',    'Cold',   'Col',    'Cmft',   'Cmn',    'Cpl',    'Cmpl',   'Cmplx',  'Cmpn',   'Cdn',    'Cfg',    'Cfgd',   'Cfmd',   'Con',    'Contns', 'Ctrld',  'Cnvinc', 'Cool',   'Coord',  'Cornr',  'Corrd',  'Corrln', 'Coupld', 'Crtr',   'Crit',   'Cubd',   'Cub',    'Crvt',   'Cyc',    'Date',   'Dctvd',  'Dbnd',   'Dec',    'Dft',    'Dfct',   'Defd',   'Deged',  'Dlt',    'Dmd',    'Dend',   'Dnmtr',  'Dens',   'Dprt',   'Dsr',    'Dtcd',   'Diagc',  'Diff',   'Dig',    'Dim',    'Dimd',   'Dir',    'Disarmed',   'Dis',    'Dpl',    'Dispd',  'Done',   'Dbl',    'Down',   'Dwnhl',  'Ds', 'Drg',    'Drvblty',    'Drv',    'Dry',    'Dummy',  'Dyn',    'Early',  'Easy',   'Eco',    'Edge',   'Efc',    'Elpd',   'Eltl',   'Electc', 'Elevn',  'Emgy',   'Emp',    'Empty',  'Emuld',  'Enad',   'End',    'Engd',   'Enhd',   'Engh',   'Equ',    'Equid',  'Equiv',  'Estimd', 'Evap',   'Even',   'Eve',    'Excdd',  'Excr',   'Excpn',  'Exist',  'Exo',    'Expd',   'Extd',   'Ext',    'Facd',   'Faild',  'Failr',  'Frd',    'Fast',   'Fav',    'FB', 'Ff', 'Ft', 'Fmale',  'Fie',    'Fild',   'Final',  'Fine',   'Finshd', 'First',  'Fixd',   'Flg',    'Flank',  'Flash',  'Flood',  'Fmt',    'Fwd',    'Free',   'Fw', 'Fr', 'Frzn',   'Full',   'Fctl',   'Gap',    'Gend',   'Gen',    'Gmtrc',  'Giga',   'Glb','Grd',    'Gr', 'Group',  'Half',   'Hptc',   'Hard',   'Hzrd',   'Heatd',  'Hvy',    'Hz', 'Hi', 'HP', 'Hist',   'Hom',    'Hozl',   'Hot',    'Hyb',    'Hyd',    'Hys',    'Id', 'Imdt',   'Impy',   'Imps',   'Impsb',  'Inc',    'Ind',    'Indct',  'Info',   'Init',   'Inp',    'Insd',   'Intgl',  'Iprt',   'Itgrtd', 'Intd',   'Intn',   'Intr',   'Ilck',   'Intery', 'Inter',  'Intm',   'Int',    'Intvl',  'Intxcn', 'Intrv',  'Ivs',    'Irrv',   'Jou',    'Kelvin', 'Keyls',  'Kilo',   'Kin',    'Lrg',    'Lst',    'Late',   'Lat',    'Lead',   'Lean',   'Left',   'Lgt',    'Lim',    'Limd',   'Limp',   'Limpho', 'Lnr',    'Lqd',    'L',  'Lcl',    'Lockd',  'Logl',   'Long',   'Lgtd',   'Loss',   'Lost',   'Ldn',    'Lo', 'Lowr',   'LP', 'Mag',    'Mgn',    'Main',   'Mntn',   'Male',   'Manv',   'Man',    'Mat',    'Max',    'Mean',   'Measd',  'Mec',    'Mecl',   'Mega',   'Memr',   'Memd',   'Mtr',    'Micro',  'Mid',    'Milli',  'Min',    'Misc',   'Miss',   'Mod',    'Mdld',   'Mod',    'Mntd',   'Mpl',    'Nat',    'Nav',    'Near',   'Neg',    'Neut',   'New',    'Nwt',    'Nxt',    'No', 'Nois',   'Nom',    'Nlnr',   'Norm',   'Now',    'Obj',    'Odd',    'Off',    'OFF',    'Offs',   'Ok', 'Old',    'On', 'ON', 'Only',   'Open',   'Opend',  'Optm',   'Opt',    'Ord',    'Outp',   'Outsd',  'Over',   'Ovf',    'Ovrhtd', 'Ovld',   'Ovrdn',  'Panic',  'Prm',    'Par',    'Ptl',    'Pa', 'Pas',    'Pat',    'Peak',   'Pnd',    'Perc',   'Perd',   'Prmnt',  'Prsnl',  'Pha',    'Phy',    'Plt',    'Plbty',  'Plaus',  'Pnm',    'Polnml', 'Pos',    'Psbl',   'Post',   'Pre',    'Pred',   'Prel',   'Prem',   'Prsnt',  'Psd',    'Prev',   'Prim',   'Prio',   'Prvt',   'Problty',    'Progd',  'P',  'Pprt',   'Prp',    'Protd',  'Prtctv', 'Qly',    'Qnty',   'Quo',    'Ramp',   'Rnd',    'Raw',    'Rchd',   'Rctv',   'Rdy',    'Real',   'Relzd',  'Re', 'Rsn',    'Recpr',  'Rcnd',   'Rcmn',   'Ref',    'Rgtv','Rgl',   'Rnst',   'Rejctd', 'Rel',    'Reld',   'Rlv',    'Rmng',   'Rem',    'Reqd',   'Rqrd',   'Resv',   'Resd',   'Resi',   'Resl',   'Rest',   'Res',    'Rvs',    'Rvsb',   'Rich',   'Right',  'Roty',   'Rotl',   'Safe',   'SSt',    'Satd',   'Saved',  'Scdr',   'Sector', 'Secu',   'Segd',   'Seld',   'Self',   'Snvty',  'Sent',   'Seq',    'Seql',   'Serl',   'Srv',    'Sp', 'Sev',    'Shrt',   'Side',   'Sgn',    'Simp',   'Simd',   'Sng',    'Slow',   'Sml',    'Smt',    'Smot',   'Soft',   'Sld',    'Sonc',   'Soon',   'Src',    'Spare',  'Spcl',   'Spc',    'Spo',    'Sqd',    'Sqrt',   'Stab',   'Stall',  'Std',    'Stb',    'Standg', 'Sndsl',  'Strtd',  'Stat',   'Stc',    'Stdy',   'Stp',    'Step',   'Srad',   'Still',  'Sti',    'Stoi',   'Strght', 'Stgy',   'Strat',  'Stuck',  'Subt',   'Sum',    'Supr',   'Suspd',  'Swil',   'Syncd',  'Tgt',    'Tmp',    'Tstd',   'Theo',   'Therm',  'Thrd',   'Thd',    'Tolr',   'Top',    'TDC',    'Tot',    'Touchd', 'Tra',    'Trv',    'Trapg',  'Trvld',  'Tro',    'Trbl',   'Turn',   'Typ',    'Undefd', 'Under',  'Unfav',  'Unlckd', 'Unstall',    'Up', 'Uppr',   'Us', 'Vanity', 'Var',    'Vari',   'Vrnt',   'Vect',   'Vers',   'Vert',   'Virt',   'Vis',    'Volt',   'Volmc',  'Wup',    'Wrm',    'Watt',   'Way',    'Wghtd',  'Wldd',   'Wide',   'WOT',    'Width',  'Wntr',   'Wishd',  'Wrg',    'Yes'};% MeanEnvironmentDevice_list
MeanEnvironmentDevice_sheet = 'MeanEnvironmentDevice'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,MeanEnvironmentDevice_list] = xlsread(file_name_str,MeanEnvironmentDevice_sheet,xlrange);  % the first thing is data,the second is text
MeanEnvironmentDevice_list(1)= []; % get rid of D1,the rest of type is cell
%方便测试,提前提取
% MeanEnvironmentDevice_list = {'ABS','Li',    'AC', 'ACC',    'Accr',   'Acsy',   'Accum',  'Actr',   'Adpt',   'AEB',    'Air',    'Airb',   'Airf',   'Alrm',   'AWD',    'Alt',    'Amb',    'Ampr',   'AMT',    'Anode',  'Aki',    'App',    'ASW',    'Armtr',  'Ash',    'Ashtray',    'Assi',   'AVH',    'Axle',   'Bank',   'Bnk',    'Bar',    'BSW',    'Batt',   'BE', 'BMU',    'BDC',    'Beam',   'Blt',    'BSG',    'Bench',  'Bcycl',  'Blk',    'Bd', 'Body',   'Bolt',   'Btldr',  'Box',    'Bpil',   'Brkt',   'Brk',    'BLS',    'Brdg',   'Bri',    'Buc',    'Buf',    'Bmp',    'Brnr',   'Bus',    'Btn',    'Buz',    'Cbn',    'Cam',    'Camsft', 'Cnst',   'Car',    'Case',   'Cat',    'Cell',   'Chmb',   'Ch', 'Chrgr',  'Chrgn',  'Chsis',  'Chd',    'Chok',   'Cgrt',   'Circ',   'Cty',    'Clmp',   'Cls',    'Clnr',   'Clk',    'Clu',    'Cch',    'Cod',    'COG',    'Coil',   'Coll',   'Cpt',    'Cmpr',   'Cdnr',   'CVT',    'Ctrlr',  'CAN',    'Cnvr',   'Coolt',  'CF', 'Coorr',  'Cntr',   'Ctrsft', 'Ctry',   'Course', 'Cpil',   'CPU',    'Crkcs',  'Crksft', 'CRBS',   'Curt',   'Crv',    'Cush',   'Cust',   'CVT',    'Cyl',    'D',  'Dampr',  'DAS',    'Dshb',   'Dash',   'Data',   'Dayti',  'DC', 'DCC',    'DCT',    'DEM',    'Demo',   'DR', 'Dev',    'Dew',    'Dsl',    'Dpf',    'Dftl',   'Dftllock',   'Dil',    'Dio',    'Dire',   'Dsk',    'Disp',   'Door',   'DM', 'Dln',    'Drvr',   'Dt', 'DTD',    'Dyno',   'EBD',    'ECU',    'EGR',    'EHB',    'Elc',    'Elm',    'Emi',    'Em', 'EMS',    'Encr',   'Eng',    'Env',    'EPB',    'Equip',  'ERAD',   'ESC',    'ESP',    'Estimr', 'Ethl',   'Euler',  'Evlr',   'Evapr',  'Exh',    'Expdr',  'Extr',   'Facy',   'Fan',    'Flt',    'File',   'Filt',   'Findr',  'Flk',    'Flap',   'Flxry',  'Flpr',   'Flr',    'Fld',    'Flywh',  'Fog',    'Fold',   'Fol',    'Foot',   'Footwell',   'Frk',    'Fu', 'Fct',    'Fuse',   'Gas',    'Gsl',    'Gate',   'Gtw',    'Gear',   'GP', 'Gbx',    'Genr',   'Glass','GD',   'Glv',    'Govr',   'Grvy',   'Grid',   'Grl',    'Gnd',    'Gulf',   'Hndbrk', 'Hdl',    'HW', 'HBA',    'HCU',    'Hd', 'Hdr',    'Hdlamp', 'Hdphn',  'Hdrest', 'Heatr',  'Hpass',  'HPP',    'HSD',    'HV', 'HVB',    'HVC',    'Hill',   'HDC',    'HHC',    'Hitch',  'HMI',    'Home',   'Hood',   'Hoop',   'Hzn',    'Horn',   'Htl',    'HVAC',   'I',  'Ice',    'Idle',   'Ign',    'Immo',   'Imp',    'IUPR',   'Indcr',  'Indctr', 'Infstr', 'Ice',    'Injr',   'Inlet',  'Inst',   'Instr',  'Intk',   'Intgr',  'Itgrtr', 'Ico',    'Interdom',   'If', 'ISG',    'Itp',    'Intscn', 'Inv',    'Jerk',   'Jctn',   'Key',    'Knee',   'Knob',   'Lamp',   'Lane',   'Lang',   'Ltch',   'Lay',    'Leak',   'LED',    'Lvr',    'Lid',    'Limr',   'Line',   'Lob',    'Loop',   'LV', 'Lpass',  'LPP',    'LSD',    'LVB',    'Lum',    'Mac',    'MIL',    'Mngt',   'Mgr',    'Mnfld',  'MT', 'Map',    'Mkr',    'Mkt',    'Mst',    'Mtrl',   'Mtrx',   'Med',    'Mem',    'Msg',    'Mtl',    'Mthl',   'Meth',   'MC', 'Mind',   'Mirr',   'Mdl',    'Mdul',   'Mol',    'Momtm',  'Monr',   'Mot',    'Motorcycle', 'Movmt',  'Mmed',   'Mux',    'Nano',   'Negn',   'Net',    'Night',  'N2', 'Nod',    'NVM',    'Nox',    'Noz',    'Obsvr',  'Obstcl', 'Obstrcn',    'Occpt',  'Oil',    'OBD',    'Opener', 'OS', 'Optic',  'Outl',   'Oxy',    'Pack',   'Pad',    'Pan',    'Passg',  'Pah',    'Pdl',    'Ped',    'Pelv',   'Pty',    'Pi', 'PID',    'Pin',    'Pinion', 'Pipe',   'Pist',   'Plate',  'Plg',    'Point',  'Ptr',    'Pool',   'Port',   'Poti',   'PT', 'Prec',   'PCV',    'Proc',   'Prof',   'Prj',    'Ppty',   'Prpsn',  'PTC',    'Puddle', 'Pls',    'Pmp',    'Pyro',   'Qf', 'Radar',  'Radr',   'Radio',  'Rail',   'Rain',   'RAM',    'RE', 'Rctnt',  'RSDS',   'RCWM',   'Rcir',   'RL', 'Regn',   'Rly',    'Rlf',    'Rmn',    'Restr',  'Rtdr',   'Rtrctr', 'Ring',   'RKE',    'Road',   'RD', 'Rollbar',    'Rollr',  'ROM',    'RON','Roof',   'Rtr',    'Route',  'Row',    'RPM',    'RSC',    'Rngbd',  'Scanr',  'Sdl',    'Seat',   'Sblt',   'Seed',   'Seg',    'Seln',   'Snsr',   'Ser',    'Servo',  'Shaft',  'Shftmp', 'Sov',    'Shnt',   'Shttr',  'Shtl',   'Sig',    'Sink',   'Sin',    'Slave',  'Sld',    'Smk',    'Snrck',  'Sckt',   'SW', 'SOI',    'Soln',   'Sound',  'Soundr', 'Sprk',   'Spkr',   'SPI',    'Splr',   'Sprg',   'SSM',    'Stabr',  'Stack',  'Stg',    'Strtr',  'SOC',    'Staty',  'Steer',  'Storg',  'Struct', 'Su', 'Sun',    'Sup',    'Surf',   'Surrndgs',   'Susp',   'Swirl',  'Swt',    'Sys',    'Tbl',    'Tank',   'Telgrm', 'Telm',   'Tensnr', 'Terminal',   'Tstbd',  'Thermo', 'Th', 'Thorax', 'Thr',    'Tmr',    'Tip',    'Tire',   'Tit',    'Tooth',  'Twbr',   'Track',  'Tcs',    'Trctr',  'Trfc',   'Trlr',   'Trsm',   'Tr', 'Tube',   'Tnl',    'Trb',    'Trbo',   'Twli',   'UDS',    'Unit',   'Urea',   'Usr',    'Vac',    'Vlv',    'Van',    'Vane',   'Vap',    'Veh',    'Vcu',    'Vlc',    'Vent',   'VIN',    'Visn',   'Wall',   'WR', 'Wnty',   'Wshct',  'Wshr',   'Wst',    'Wg', 'Wdg',    'Wtr',    'WV', 'Wthr',   'Whl',    'Whls',   'Wndg',   'Windw',  'WS', 'Wipr',   'Wire',   'Wirels', 'Word',   'World'};% Preposition_list
Preposition_sheet = 'Preposition'; % pay attention names ,english name is ok
xlrange = 'B:B';
[~,Preposition_list] = xlsread(file_name_str,Preposition_sheet,xlrange);  % the first thing is data,the second is text
Preposition_list(1)= []; % get rid of D1,the rest of type is cell
%方便测试,提前提取
% Preposition_list= {'Aft',  'Ahd',    'And',    'At', 'Blw',    'Botm',   'By', 'Dur',    'For',    'From',   'In', 'Not',    'Of', 'Or', 'Out',    'Per',    'To', 'Vs', 'With',   'Within', 'Wo'};%% 进行依次判断
need_write_sheet = '变量表';
number_0_9_Table = {'0','1','2','3','4','5','6','7','8','9'};process_show=waitbar(0,'检查进度'); %显示初始界面
%特殊的1X对应的数据类型
special_type_data='';for temp_total=1:length(Total_variable_list)test_variable_name = char(Total_variable_list(temp_total));Percentage = temp_total/length(Total_variable_list);waitbar(Percentage,process_show,['已完成'  (num2str(round(100*Percentage)))  '%']); %进度条,进度增加情况 后面有判断是否关闭%% First check variable lengthif length(test_variable_name) > 31 || (length(test_variable_name)==0)result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = {'Variable naming length should meet the requirements! or the data is empty '};write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环endif (sum(strcmp(char(test_variable_name(1)),Type_identifier_list)) >= 1) %判断 第一个字母 >=是防止有多个查询if numel(strfind(char(test_variable_name),'_'))~=2 %表示有3段_,共两个下划线result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C =  strcat({'component name error01: '},'need two _'); % matlab中的cell类型要转换成str之后在进行拼接;write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环end%% 前面已经进行拆分  只有两个下划线 Vu32BattLimt_BMSVCUBattSoc_Nm; VtTrqLimt_VehSpdBattSoc1Y_flg; VmTrqLimt_VehSpdBattSoc2Z_enumif numel(strfind(char(test_variable_name),'_'))==2 %  重复判断,后期删除CheckDifferentBlock=regexp(test_variable_name,'_','split'); %根据下划线分隔为成3部分%% 第3部分判断和第1部分判断if (sum(strcmp(char(CheckDifferentBlock(3)),unit_type_list)) >= 1) % 如果第3个部分符合单位的简化要求% 处理第一部分Re_Expression = '[A-Z]+[0-9]*[a-z]*[0-9]*[a-z]*[0-9]*'; % 正则表达式用来匹配类似ABVeh的缩写matchStr = regexp(char(CheckDifferentBlock(1)),Re_Expression,'match');[matchStr_size,~] = size(char(matchStr)); %求出可以分为几部分!! !% 特殊情况宏变量:Mf_RvsTq_pctif matchStr_size==1 %表示第一部分只有一个大写字母,判断结束之后记得加continue;%对第一部分的类型标识符和数据类型进行判断 ,由于第一个大写字母为类型标识符,已经判断过!Macro_variable_special=char(matchStr(matchStr_size));Macro_variable_special(1)=[]; %删除第一个类型标识符special_type_data=Macro_variable_special;if(sum(strcmp(char(Macro_variable_special),Type_of_data_list)) < 1) %数据类型没找到%报错result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Type identifier  error63: '},Macro_variable_special); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环end%进行第2部分的判断即可special_second_block =char(CheckDifferentBlock(2));% 特殊情况判断if(sum(strcmp(char(special_second_block(length(special_second_block)-1:end)),Extended_description_list)) >= 1)if special_second_block(length(special_second_block)-1)=='1'  % 特殊情况判断:1X,1Y-->t;if(special_type_data~='t')%报错result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'1X,1Y must  match t.Matching error25: '},special_type_data); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环endelseif(special_second_block(length(special_second_block)-1)=='2') % 特殊情况判断:2X,2Y,2Z-->mif(special_type_data~='m')%报错result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'2X,2Y,2Z must  match m.Matching error26: '},special_type_data); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环endelse%报错result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'the last two letter is wrong,Matching error23: '},special_second_block(length(special_second_block)-1:end)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环end%把CheckDifferentBlock(2)中最后两个元素给去掉special_second_block(length(special_second_block)-1:end)=[];endif (sum(strcmp(char(CheckDifferentBlock(3)),unit_type_list)) >= 1) % 如果第3个部分符合单位的简化要求% 处理第二部分Re_Expression = '[A-Z]+[0-9]*[a-z]*[0-9]*[a-z]*[0-9]*'; % 正则表达式用来匹配类似ABVeh的缩写matchStr = regexp(char(special_second_block),Re_Expression,'match');[matchStr_size,~] = size(char(matchStr)); %求出可以分为几部分!! !total_split_section = {}; %用来记录一共拆分为几部分for temp=1:matchStr_size % 注意此处不能用size求总数!这是外循环,求出Veh BMSSpd VCUSign Ena if length(char(regexp(char(matchStr(temp)),'[A-Z]+','match'))) > 1  %中 大写字母的个数大于1,则下面运算%% 取出全是大写字母的情况 matchStrtest_Split_All_Capital_TypematchStrtest_Split = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match')); %得到BMSSmatchStrtest_Split_All_Capital_Type_total = matchStrtest_Split(1:end-1); %得到BMS if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_All_Capital_Type_total(end)=[];endif (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_All_Capital_Type_total(end)=[];endif length(matchStrtest_Split_All_Capital_Type_total) >= 6 %限制只能是3的倍数,并且是只能是三个一段length_3_Split_All_Capital_Type = floor(length(matchStrtest_Split_All_Capital_Type_total)/3); % 查看有几段是是三个字母的% disp(length_3_Split_All_Capital_Type);for length_3_temp = 0 : (length_3_Split_All_Capital_Type-1)matchStrtest_Split_All_Capital_Type = matchStrtest_Split_All_Capital_Type_total((3*(length_3_temp)+1):(length_3_temp+1)*3); % 满足{(1,3),(4,6),(7,9)}等 即需要大写必须是3个一组total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去end else % 如果小于6就直接进行判断matchStrtest_Split_All_Capital_Type =  matchStrtest_Split_All_Capital_Type_total; % 如果大写字母长度小于6直接进行判断total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去end%% 取出第一个大写字母+后面小写的情况 matchStrtest_Split_First_Capital_TypematchStrtest_Capital = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match'));The_first_Capital = matchStrtest_Capital(end);  %取出第一个大写字母 char类型 得到S later_letter = char(regexp(char(matchStr(temp)),'[a-z]+[0-9]*[a-z]+[0-9]*','match'));% 得到pdif length(later_letter)==0 % 表示出现特殊情况:如VfLiTq_RvsSOC_Pct中的SOC的C最后没有小写字母的情况matchStrtest_Split_First_Capital_Type=matchStrtest_Capital;elsematchStrtest_Split_First_Capital_Type = strcat(The_first_Capital,later_letter); %得到Spdendif (sum(strcmp(char(matchStrtest_Split_First_Capital_Type(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_First_Capital_Type(end)=[];endtotal_split_section = [total_split_section , matchStrtest_Split_First_Capital_Type]; %添加进去else    %只有一个大写字母 按照之前判断就可以了 比如:Spdif temp==0 % 永远不会成立continue;elsejudge_number = char(matchStr(temp));         if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数,所以两次judge_number(end)=[];endif (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数judge_number(end)=[];endtotal_split_section = [total_split_section , judge_number]; %用来记录一共拆分为几部分endend   end  %% 后续在这里对total_split_section进行判断current_position=1;next_position = 1;Internal_error_flag=0;%内部错误标志位,表示内部的其他错误,比如没查询到等for split_tmp=1:length(total_split_section)%total_split_section(split_tmp) %测试if split_tmp==1 %给定初始值,并设定两个位置游标,进行游标判断if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)current_position = 1;next_position = 1;elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)current_position = 2;next_position = 2;elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)current_position = 3;next_position = 3;elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)current_position = 4;next_position = 4;elseInternal_error_flag=1;%内部标志位result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error39: '},total_split_section(split_tmp)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break; % 结束最里面的循环  endcurrent_position = next_position; %再次确保两者初始值相等else%求出下一个游标位置if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)next_position = 1;elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)next_position = 2;elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)next_position = 3;elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)next_position = 4;else%报错,表示当前没有找到 %结束当前变量查询Internal_error_flag=1;%内部标志位result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error56: '},total_split_section(split_tmp)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break; % 结束最里面的循环 end%游标位置的比较if next_position >= current_positioncurrent_position = next_position; % 把此次游标的位置记录,方便后面比较else %位置对应的顺序不符报错Internal_error_flag=1;%内部标志位result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'The two section  sequence error36: '},total_split_section(split_tmp),' and  ',total_split_section(split_tmp-1)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break;  % 结束最里面的循环 endendif Internal_error_flag==0 %内部标志位是0,即内部无错误result_B = {'Pass'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'NULL'});write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); endendcontinue; %结束此次宏变量的判断,之前把正确的结果写入else %表示第3部分不符要求result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'unit_type_list name error15: '},char(CheckDifferentBlock(3)));write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue;endend%% 第一部分有多个大写+小写的情况Internal_error_flag=0;for temp=1:matchStr_size % 注意此处不能用size求总数!这是外循环,求出Veh BMSSpd VCUSign Ena if length(char(regexp(char(matchStr(temp)),'[A-Z]+','match'))) > 1  %中 大写字母的个数大于1,则下面运算%% 取出全是大写字母的情况 matchStrtest_Split_All_Capital_TypematchStrtest_Split = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match')); %得到BMSSmatchStrtest_Split_All_Capital_Type_total = matchStrtest_Split(1:end-1); %得到BMS if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_All_Capital_Type_total(end)=[];endif (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_All_Capital_Type_total(end)=[];endif length(matchStrtest_Split_All_Capital_Type_total) >= 6 %限制只能是3的倍数,并且是只能是三个一段length_3_Split_All_Capital_Type = floor(length(matchStrtest_Split_All_Capital_Type_total)/3); % 查看有几段是是三个字母的% disp(length_3_Split_All_Capital_Type);for length_3_temp = 0 : (length_3_Split_All_Capital_Type-1)matchStrtest_Split_All_Capital_Type = matchStrtest_Split_All_Capital_Type_total((3*(length_3_temp)+1):(length_3_temp+1)*3); % 满足{(1,3),(4,6),(7,9)}等 即需要大写必须是3个一组Logical_Flag_Result = (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ActionPhysicalType_list)) >= 1) || (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ConditionQualifier_list)) >= 1) ;if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),MeanEnvironmentDevice_list)) >= 1) || Logical_Flag_Result ; % 如果第一个部分符合组件的简化要求 %表示无错误,测试使用;elseInternal_error_flag=1;result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error73: '},matchStrtest_Split_All_Capital_Type); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环    endend else % 如果小于6就直接进行判断matchStrtest_Split_All_Capital_Type =  matchStrtest_Split_All_Capital_Type_total; % 如果大写字母长度小于6直接进行判断Logical_Flag_Result = (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ActionPhysicalType_list)) >= 1) || (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),ConditionQualifier_list)) >= 1) ;if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type),MeanEnvironmentDevice_list)) >= 1) || Logical_Flag_Result ; % 如果第一个部分符合组件的简化要求 %set(handles.result_suggest,'string','NULL_33'); %测试使用;elseInternal_error_flag=1;result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error31: '},matchStrtest_Split_All_Capital_Type); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环    endend%% 取出第一个大写字母+后面小写的情况 matchStrtest_Split_First_Capital_TypematchStrtest_Capital = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match'));The_first_Capital = matchStrtest_Capital(end);  %取出第一个大写字母 char类型 得到S later_letter = char(regexp(char(matchStr(temp)),'[a-z]+[0-9]*[a-z]+[0-9]*','match'));% 得到pdif length(later_letter)==0 % 表示出现特殊情况:如VfLiTq_RvsSOC_Pct中的SOC的C最后没有小写字母的情况matchStrtest_Split_First_Capital_Type=matchStrtest_Capital;elsematchStrtest_Split_First_Capital_Type = strcat(The_first_Capital,later_letter); %得到Spdendif (sum(strcmp(char(matchStrtest_Split_First_Capital_Type),Abbreviation_Total_Table)) >= 1); % 如果第二个部分符合组件的简化要求 比如:Spd  %测试使用;elseInternal_error_flag=1;result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C =  strcat({'Abbreviation name error22: '},matchStrtest_Split_First_Capital_Type);write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环     end else    %只有一个大写字母 按照之前判断就可以了 比如:Spdif temp==1 % 表示是Vu32first_little_leter = char(matchStr(temp));first_little_leter(1)=[]; %删除第一个字母Vspecial_type_data = first_little_leter;% 因为后面可能需要进行判断,如1X等特殊情况判断if (sum(strcmp(char((special_type_data)),Type_of_data_list)) == 0) %表示没找到u32之类的数据类型result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C =  strcat({'type data name error23: '},char(matchStr(temp))); % matlab中的cell类型要转换成str之后在进行拼接;write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); endelsejudge_number = char(matchStr(temp));         if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数,所以两次judge_number(end)=[];endif (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数judge_number(end)=[];endif (sum(strcmp(char((judge_number)),ActionPhysicalType_list)) >= 1) | (sum(strcmp(char((judge_number)),ConditionQualifier_list)) >= 1) | (sum(strcmp(char((judge_number)),MeanEnvironmentDevice_list)) >= 1)% 如果第二个部分符合组件的简化要求 %set(handles.result_suggest,'string','NULL_11'); %测试使用;elseInternal_error_flag=1;result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error11: '},char(matchStr(temp)));write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break; % 结束最里面的循环   end endend   end  if Internal_error_flag==0 %内部标志位是0,即内部无错误result_B = {'Pass'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'NULL'});write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); endelse %表示第3部分不符要求result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'unit_type_list name error15: '},char(CheckDifferentBlock(3)));write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue;end%% 处理第三部分和第二部分判断(:第三部分是重复判断)% 特殊情况判断:1X,1Y-->t; 2X,2Y,2Z-->mspecial_second_block =char(CheckDifferentBlock(2));% 特殊情况判断if(sum(strcmp(char(special_second_block(length(special_second_block)-1:end)),Extended_description_list)) >= 1)if special_second_block(length(special_second_block)-1)=='1'  % 特殊情况判断:1X,1Y-->t;if(special_type_data~='t')%报错result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'1X,1Y must  match t.Matching error25: '},special_type_data); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环endelseif(special_second_block(length(special_second_block)-1)=='2') % 特殊情况判断:2X,2Y,2Z-->mif(special_type_data~='m')%报错result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'2X,2Y,2Z must  match m.Matching error26: '},special_type_data); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环endelse%报错result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'the last two letter is wrong,Matching error23: '},special_second_block(length(special_second_block)-1:end)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环end%把CheckDifferentBlock(2)中最后两个元素给去掉special_second_block(length(special_second_block)-1:end)=[];              endif (sum(strcmp(char(CheckDifferentBlock(3)),unit_type_list)) >= 1) % 如果第3个部分符合单位的简化要求% 处理第二部分Re_Expression = '[A-Z]+[0-9]*[a-z]*[0-9]*[a-z]*[0-9]*'; % 正则表达式用来匹配类似ABVeh的缩写matchStr = regexp(char(special_second_block),Re_Expression,'match');[matchStr_size,~] = size(char(matchStr)); %求出可以分为几部分!! !total_split_section = {}; %用来记录一共拆分为几部分for temp=1:matchStr_size % 注意此处不能用size求总数!这是外循环,求出Veh BMSSpd VCUSign Ena if length(char(regexp(char(matchStr(temp)),'[A-Z]+','match'))) > 1  %中 大写字母的个数大于1,则下面运算%% 取出全是大写字母的情况 matchStrtest_Split_All_Capital_TypematchStrtest_Split = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match')); %得到BMSSmatchStrtest_Split_All_Capital_Type_total = matchStrtest_Split(1:end-1); %得到BMS if (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_All_Capital_Type_total(end)=[];endif (sum(strcmp(char(matchStrtest_Split_All_Capital_Type_total(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_All_Capital_Type_total(end)=[];endif length(matchStrtest_Split_All_Capital_Type_total) >= 6 %限制只能是3的倍数,并且是只能是三个一段length_3_Split_All_Capital_Type = floor(length(matchStrtest_Split_All_Capital_Type_total)/3); % 查看有几段是是三个字母的% disp(length_3_Split_All_Capital_Type);for length_3_temp = 0 : (length_3_Split_All_Capital_Type-1)matchStrtest_Split_All_Capital_Type = matchStrtest_Split_All_Capital_Type_total((3*(length_3_temp)+1):(length_3_temp+1)*3); % 满足{(1,3),(4,6),(7,9)}等 即需要大写必须是3个一组total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去end else % 如果小于6就直接进行判断matchStrtest_Split_All_Capital_Type =  matchStrtest_Split_All_Capital_Type_total; % 如果大写字母长度小于6直接进行判断total_split_section = [total_split_section , matchStrtest_Split_All_Capital_Type]; %添加进去end%% 取出第一个大写字母+后面小写的情况 matchStrtest_Split_First_Capital_TypematchStrtest_Capital = char(regexp(char(matchStr(temp)),'[A-Z]+[0-9]*[A-Z]+[0-9]*','match'));The_first_Capital = matchStrtest_Capital(end);  %取出第一个大写字母 char类型 得到S later_letter = char(regexp(char(matchStr(temp)),'[a-z]+[0-9]*[a-z]+[0-9]*','match'));% 得到pdif length(later_letter)==0 % 表示出现特殊情况:如VfLiTq_RvsSOC_Pct中的SOC的C最后没有小写字母的情况matchStrtest_Split_First_Capital_Type=matchStrtest_Capital;elsematchStrtest_Split_First_Capital_Type = strcat(The_first_Capital,later_letter); %得到Spdendif (sum(strcmp(char(matchStrtest_Split_First_Capital_Type(end)),number_0_9_Table)) >= 1) % 如果最后两个是数字就去掉matchStrtest_Split_First_Capital_Type(end)=[];endtotal_split_section = [total_split_section , matchStrtest_Split_First_Capital_Type]; %添加进去else    %只有一个大写字母 按照之前判断就可以了 比如:Spdif temp==0 % 永远不会成立continue;elsejudge_number = char(matchStr(temp));         if (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数,所以两次judge_number(end)=[];endif (sum(strcmp(char(judge_number(end)),number_0_9_Table)) >= 1)  % 如果最后一个是数字就去掉,一般后面最多两位数judge_number(end)=[];endtotal_split_section = [total_split_section , judge_number]; %用来记录一共拆分为几部分endend   end  %% 后续在这里对total_split_section进行判断current_position=1;next_position = 1;Internal_error_flag=0;%内部标志位是0,即内部无错误for split_tmp=1:length(total_split_section)%total_split_section(split_tmp) %测试if split_tmp==1 %给定初始值,并设定两个位置游标,进行游标判断if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)current_position = 1;next_position = 1;elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)current_position = 2;next_position = 2;elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)current_position = 3;next_position = 3;elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)current_position = 4;next_position = 4;elseInternal_error_flag=1;%内部标志位是0,即内部无错误result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error39: '},total_split_section(split_tmp)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break; % 结束最里面的循环 endcurrent_position = next_position; %再次确保两者初始值相等else%求出下一个游标位置if (sum(strcmp(char(total_split_section(split_tmp)),MeanEnvironmentDevice_list)) >= 1)next_position = 1;elseif(sum(strcmp(char(total_split_section(split_tmp)),ConditionQualifier_list)) >= 1)next_position = 2;elseif(sum(strcmp(char(total_split_section(split_tmp)),Preposition_list)) >= 1)next_position = 3;elseif(sum(strcmp(char(total_split_section(split_tmp)),ActionPhysicalType_list)) >= 1)next_position = 4;else%报错,表示当前没有找到 %结束当前变量查询Internal_error_flag=1;%内部标志位是0,即内部无错误result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'Abbreviation name error56: '},total_split_section(split_tmp)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break; % 结束最里面的循环  end%游标位置的比较if next_position >= current_positioncurrent_position = next_position; % 把此次游标的位置记录,方便后面比较else %位置对应的顺序不符报错Internal_error_flag=1;%内部标志位是0,即内部无错误result_B ={ 'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'The two section  sequence error36: '},total_split_section(split_tmp),' and  ',total_split_section(split_tmp-1)); write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); break; % 结束最里面的循环  endendif Internal_error_flag==0 %内部标志位是0,即内部无错误result_B = {'Pass'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'NULL'});write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); endend %表示第二部分的每个部分也判断结束,最后会有结论出来的else %表示第3部分不符要求result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'unit_type_list name error15: '},char(CheckDifferentBlock(3)));write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue;endend % 第二层判断!!else % 第一层判断第一个字母是否正确!!result_B = {'Failed'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = {'The first capital letter corresponds to the type identifier is incorrect'}; write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); continue; % 结束循环中的第n次,继续n+1次循环end  %第一层第一个变量判断% 得出结论,通过if Internal_error_flag==0 %内部标志位是0,即内部无错误result_B = {'Pass'};write_region_B = char(strcat('B',num2str(temp_total+1)));xlswrite(file_name_str,result_B,need_write_sheet,write_region_B); %把B列写入结果suggestion_C = strcat({'NULL'});write_region_C = char(strcat('C',num2str(temp_total+1)));xlswrite(file_name_str,suggestion_C,need_write_sheet,write_region_C); endend
close(process_show);%关闭进度条
disp('程序运行结束.');

matlab之用m脚本自动完成检查变量命名规范相关推荐

  1. matlab之用m脚本自动生成exe文件

    matlab之用m脚本自动生成exe文件 文章目录 matlab之用m脚本自动生成exe文件 0.前言 1.生成exe文件分两种情况 2.生成文件在自己电脑上运行 3.生成文件在其他电脑上运行 0.前 ...

  2. [转]WinXP、Win7脚本自动加域及用户资料迁移

    原文地址 http://shubao.blog.51cto.com/401810/710102 WinXP.Win7脚本自动加域及用户资料迁移 最近公司要上AD域项目,所有的用户全部从工作组环境切换到 ...

  3. Ubuntu/CentOS下使用脚本自动安装 Docker

    Ubuntu.Debian 系列安装 Docker 系统要求 Docker 支持以下版本的 Ubuntu 和 Debian 操作系统: Ubuntu Xenial 16.04 (LTS) Ubuntu ...

  4. 脚本自动定时打开链接_自动化构建系统

    在软件开发过程中,特别是在一些大型多人合作开发的项目中,如何将各个人开发的不同模块集合为一个完整的系统,最终输出一个完整的目标文件,这个过程包括编译,发布,自动化测试等环节.这一过程的完善程度和流畅程 ...

  5. 树莓派USB存储设备自动挂载并通过脚本实现自动拷贝,自动播放视频,脚本自动升级等功能...

    需求: 首先需要树莓派自动挂载USB设备,然后扫描USB指定目录下文件,将相关文件拷贝至树莓派指定目录,然后通过omxplayer循环播放新拷贝文件视频 1. 树莓派实现USB存储设备自动挂载 树莓派 ...

  6. WinXP、Win7脚本自动加域及用户资料迁移(一)

    WinXP.Win7脚本自动加域及用户资料迁移(一) 最近公司要上AD域项目,所有的用户全部从工作组环境切换到域环境,本地账号迁移到域账号.因客户端比较多,仔细研究了一下微软的加域和用户迁移工具,结合 ...

  7. 斧子演示_用斧头进行自动辅助功能检查

    斧子演示 How much time and effort did you spend planning the design of your last website to be accessibl ...

  8. 用斧头进行自动辅助功能检查

    您花了多少时间和精力来计划上一个网站的设计,以使有特殊需要和残障的人可以访问? 我有一种预感,许多读者的答案将是"无". 但是几乎没有人会否认,由于辨别颜色,阅读文字,使用鼠标或只 ...

  9. 【AirTest实例】1.使用脚本自动跑通游戏引导

    本人测试岗位,在项目不是很忙的时候,还是想写一个可以自动跑的游戏脚本.挂着游戏能够代替一些手动的测试,并且闲时晚上下班的时候挂着手机,第二天再来看报告日志,算是物尽其用了.前期脚本基础功能是要在编辑器 ...

最新文章

  1. 一张图看懂微软人工智能
  2. 一个小小指针,竟把Linux内核攻陷了!
  3. kafka的SASL的适用业务场景
  4. 直线电机原理动画_最新的3D动画演示:同步电机原理及技术,一般人看不懂
  5. 监控工具之zabbix server3.4 部署配置
  6. LeetCode LCS 02. 完成一半题目(计数+排序)
  7. linux计算目录下wc,Linux wc命令详解
  8. HTTP header location 重定向 URL
  9. 路由器三种口令的设置
  10. CVE-2021-35464: ForgeRock AM远程代码执行漏洞
  11. 封装的ini文件类。保存为unicode的。解决delphi xe的TiniFile保存后不为unicode的问题...
  12. 经典面试题 之 JVM调优
  13. xp计算机找不到音量调节,关于电脑声音小喇叭图标XP中不见没有声音的恢复教程...
  14. matlab单字音频合成,基于MATLAB的音频解析与合成
  15. The SDK seems invalid 问题处理
  16. CMD窗口下进入PowerShell和退出PowerShell
  17. 【渝粤题库】陕西师范大学165205 组织设计与人力资源规划 作业(专升本)
  18. 厉害了!你的技术真的到天花板了吗?年薪50W
  19. Twig中控制保留小数位数
  20. 软件产品经理的岗位职责与要求

热门文章

  1. 在SpringMVC项目中使用HIkariCP
  2. 【无标题】关于DBC文件的格式解析(DBC文件系列其二)
  3. c++ http gzip压缩解压缩
  4. 学习笔记——CDQ分治
  5. markdown文本居中,段首缩进的方法
  6. android加入聊天功能,app实现聊天功能 - houwanmin的个人空间 - OSCHINA - 中文开源技术交流社区...
  7. oracle新建用户并授权视图
  8. Kubernetes(k8s)基础之二:容器编排介绍及概念
  9. Shiro安全框架(Shiro与SpringBoot整合开发)之图片验证码(五)
  10. 长春哪个学校可以学习计算机编程的,长春编程学习,长春学编程的学校,长春学编程自学好还是报班好 - IT教育频道...