通过表格形式显示数组,语法如下Syntaxtable([,,...,],,,)Inputarray_1Anarrayofvaluesforcolumn1.array_2Anoptionalarrayofvaluesforcolumn2.array_nAnoptionalarrayofvaluesforcolumnn.formatAformatdescriptorforeachcolumninthetable.fromTheindexofthefirstelementineachcolumn.toTheindexofthelastelementineachcolumn.{label={"zero","one","two","three","four"}}{c0={"","I","II","III","IV","V","VI"}}{c1={0,1,2,3,4,5,6}}{table(label,c0,c1,"%8s%8s%4d",0,3)}{label={"zero","one","two","three","four"}}{c0={"","I","II","III","IV","V","VI"}}{c1={0,1,2,3,4,5,6}}{table(label,c0,c1,"%8s%8s%4d",0,4)}{label={"zero","one","two","three","four"}}{c0={"","I","II","III","IV","V","VI"}}{c1={0,1,2,3,4,5,6}}{table(label,c0,c1,"%8s%8s%4d",1,6)}设置字符的格式语法如下:Syntaxformat,%[].[][],[]InputwidthAnoptionalparameterthatspecifiestheminimumnumberofcharacterstobeprinted.precisionAnoptionalparameterthatspecifiesthenumberofdigitstotherightofthedecimalpoint.typeAnoptionalparameterthatspecifiestheformatoftheoutput:i/dintegerffloatingpointe/Escientificnotationg/Gauto-formatooctalx/Xhexadecimalc/Csinglecharacters/SstringoptionalparameterAnoptionalparameterthatdisplaystheoutputinoneofthreeformats:Displaysthecontentsofanarrayascomma-separatedlists.Displaysthecontentsofanarrayaselementsinsideofbraceswitheachelementinthearraysurroundedbybracesandseparatedbycommas.Displaysthecontentsofanarrayasrowsandcolumnsofvaluesboundedbyverticalbars.{format,%i,list}{square1={{1.3,2.9},{3.1,4.2}}}{square1}{square1,%i,array}{square1,%i,matrix}Template:{format,%9.7f}{sin(PI/4)}{sin(PI/4),%5.2f}Output:0.70710670.71计算线性方程3x+4y+9z=295x-3y+z=16x+y+z=4{x_coeffs={3,5,1}}{y_coeffs={4,-3,1}}{z_coeffs={9,1,1}}{rhs={29,16,4}'}{lhs={x_coeffs,y_coeffs,z_coeffs}'}{format,%5.2f,matrix}coefficientmatrix:{lhs}righthandside:{rhs}determinant:{determinant(lhs)}inverse:{inverse(lhs),%7.4f}inversetimesoriginal:{inverse(lhs)*lhs}answer:{inverse(lhs)*rhs}FormattingGuidelinesFormattinggeneraloutput,numericoutput,characterandstringoutput,andmatrices.OutputTemplexwritestexttothespecifiedoutputstreamexactlyasitappearsinthetemplate.Forexample:{X=3}WhatisX+2?Theansweris:{X+2}appearsas:WhatisX+2?Theansweris:5TemplexusesstandardCformatdescriptorstoformatnumericandstringoutput.Formatdescriptorsreserveaspecificamountofspaceintheoutputtextforthevalue.Ifmorespaceisreservedthanthevaluerequires,theoutputtextispaddedwithspaces.Numericalvaluesarerightjustified.Stringvaluesareleftjustified.Ifnoformatisspecified,eachdatatypeusesthedefaultformatassociatedwitheachvariabletypeorthedefaulttemplateformatandtheoutputisnotpadded.AdefaulttemplateformatiscreatedusingtheTemplexstatement.formatFormatdescriptorsareplacedattheendofanexpression.Theyareseparatedfromtheexpressionbyacommaandprecededbyapercentsign,%.Thefollowingexamplesillustratethesyntax:{sqrt(100),%5d}{cos(t)+sin(3.1415/phi),%12.5f}Ofthetwelvespacesinthesecondexample,fivespacesareusedtodisplaythevaluestotherightofthedecimalpoint.Onespaceisreservedforthedecimalpoint.Thesixremainingspacesappeartotheleftofthedecimalpointasablankandazero.Extraspacedoesnotneedtobereservedfortheleadingplus/minussign.Someoperatingsystemsdisplayablankinsteadofaplussign.NumericOutputIntegerandrealvaluescanbedisplayedinsixoutputformats:integeroctal,hexadecimal,floatingpoint,scientificnotation,andvaluedependent.Descriptorsfortheseformatsandexamplesoftheirusearegiveninthefollowingtable.DataFormatDescriptorExampleOutputIntegerdori{sqrt(10000),%5d}{sin(PI/4),%5i}••100••••0Octalo{100,%4o}•144HexadecimalxorX{100,%4X}••64Floatingpointf{sin(PI/4),%6.3f}•0.707ScientificnotationeorE{sin(PI/4),%10.3e}{sin(PI/4),%10.3E}+0.707e+00+0.707E+00Value-dependentgorG{sin(PI/4),%10.3g}{100,%7.3f}•••••0.707100.000Note:The•intheoutputcolumnindicatesblankspaceswhichareusedtopadtheoutputifthereservedspaceisnotcompletelyused.The•doesnotappearinyouroutput.Theanddescriptorsautomaticallydeterminewhetherafixeddecimalorexponentialnotationformatshouldbeused,dependingonthemagnitudeoftheresult.Ifthemagnitudeofthevalueislarge,thedescriptorusesacapitalintheexponent,dependingonyouroperatingsystem’sdefaults.gGGECharacterandStringOutputCharacterandstringvaluescanbedisplayedintwooutputformats,assinglecharactersorasstrings.Descriptorsfortheseformatsandexamplesoftheirusearegiveninthefollowingtable:DataFormatDescriptorExampleOutputsinglecharacterc{65,%c}Acharacterstrings{"Thisisastring",%.12s}ThisisastTemplexnowsupportsforeigncharacterswithanewregistrykey,.Settingtheregistrykeytoignoresforeigncharacterswhilesettingtheregistrykeytosupportsthem.YoumustrestartTemplextoseethechangeasitonlychecksthisregistrykeyatstartup.templex.hichar01MatricesMatricescanbedisplayedinthreeoutputformats:asacomma-separatedlist,asalistofelementsinsidebraces,andasrowsandcolumnsofnumbers.Theparametersforthesethreeformatsandexamplesofeacharegiveninthefollowingtable:DataFormatDescriptorExampleOutputcomma-separatedlistslist{format,%i,list}{square1={{1.3,2.9},{3.1,4.2}}}{square1}{1,2},{3,4}elementsinsideofbracesarray{format,%i,array}{square1={{1.3,2.9},{3.1,4.2}}}{square1}{{1,2},{3,4}}rowsandcolumnsmatrix{format,%3.1f,matrix}{square1={{1.3,2.9},{3.1,4.2}}}{square1}|1.32.9||||3.14.2|来源:TodayCAEer