Matlab介绍IntroductiontoMatlab 分享兴趣,传播快乐,增长见闻,留下美好。 亲爱的您, 这里是LearingYard学苑! 今天小编为大家带来matlab介绍 欢迎您的用心访问! 本期推文阅读时长大约6分钟,请您耐心阅读。 Shareinterest,spreadhappiness,increaseknowledge,andleavebeautiful。 Dearyou, ThisistheLearingYardAcademy! Today,theeditorbringsyouanintroductiontomatlab Welcomeyourvisit! Thistweetusuallytakesabout6minutestoread,pleasereaditpatiently。 01本期主题介绍 Thetopicofthisissue 如果您学会使用Matlab, 将有一个科研小助手,做事更轻松! 本期话题将对matlab做一个基础介绍。 Matlab的功能多样, 这里介绍一下Matlab入门级的基本功能, 目的是给没有接触过Matlab的朋友学习参考。 所以,请感兴趣的朋友和小编开启学习Matlab的旅程吧! IfyoucanuseMatlab,youwillhaveanadditionalresearchassistant。 Dothingsmoreeasily! Thetopicofthisissuewilldoatweetintroductiontomatlab。 ThefunctionsofMatlabarequiteperse, HereisanintroductiontothebasicfunctionsofMatlabentrylevel, ThepurposeistolearnreferenceforfriendswhohavenotcontactedMatlab。 So, Pleaseopenwithinterestedfriendsandeditors LetsgettoknowthejourneyofMatlab! 02Matlab软件介绍 Matlabsoftwareintroduction MATLAB是美国MathWorks公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境 MATLABisacommercialmathematicalsoftwareproducedbyMathWorks,ahighleveltechnicalcomputinglanguageandinteractiveenvironmentforalgorithmdevelopment,datavisualization,dataanalysis,andnumericalcalculation。 主要用途: (1)数值和符号计算; (2)绘图; (3)工具箱(Toolbox),分为功能性和学科性两种类。 使用技巧:Help 输入helpfunname(函数名),即可以得到函数的相关帮助信息。 Themainpurpose: (1)N (2)D (3)Toolbox(Toolbox)ispidedintotwocategories:functionalanddisciplinary。 Useskills:Help Enterhelpfunname(functionname)togethelpinformationaboutthefunction。 03Matlab基础界面介绍 Matlabbasicinterfaceintroduction 1。Matlab的基础界面ThebasicinterfaceofMatlab 1)菜单工具栏 2)文件目录 3)命令窗口:交互式地控制Matlab。比如,简单计算,函数命令测试等。 4)数据区:命令中使用的变量、导入的数据、执行的脚本后的数据都会显示在此处。 5)代码编辑区:编辑代码,按菜单栏运行Matlab便可执行。 1)Menutoolbar 2)Filedirectory 3)Commandwindow:ControlMatlabinteractively。Forexample,simplecalculation,functioncommandtest,etc。 4)Dataarea:Thevariablesusedinthecommand,theimporteddata,andthedataaftertheexecutedscriptwillallbedisplayedhere。 5)Codeeditingarea:EditthecodeandpressRunMatlabinthemenubartoexecuteit。 04Matlab基本使用介绍 IntroductiontothebasicuseofMatlab 1。命令窗口的使用(绘制正弦曲线和余弦曲线) Theuseofthecommandwindow(drawingsinecurveandcosinecurve) 操作:在命令窗口输入 x〔0:0。5:360〕pi180;plot(x,sin(x),x,cos(x)); Operation:Enterinthecommandwindow x〔0:0。5:360〕pi180;plot(x,sin(x),x,cos(x)); 2。变量命名规则 2。Variablenamingrules 1、变量赋值 1。Variableassignment 变量命名:以字母开头,后接字母、数字或下划线的字符序列,最多63个字符;变量名区分字母的大小写。 变量赋值:变量名表达式 表达式〔自动赋值给变量ANS〕 举例:在命令窗口输入 x12i,y3sqrt(17) z(cos(abs(xy))sin(78pi180))(xabs(y)) Variablenaming:startwithaletter,followedbyasequenceofletters,numbersorunderscores,upto63variablenamesarecasesensitive Variableassignment:variablenameexpression Expression〔automaticallyassignedtovariableANS〕 Example:Enterinthecommandwindow x12i,y3sqrt(17) z(cos(abs(xy))sin(78pi180))(xabs(y)) 3。矩阵操作(Matrixoperation) 1)矩阵的建立 直接输入法:将矩阵元素用方括号括起来,按矩阵行的顺序输入各元素,同一行各元素之间用空格或逗号分隔,不同行的元素之间用分号分隔 2)利用冒号表达式建立一个行向量:e1:e2:e3 其中e1为初始值,e2为步长,e3为终止值;定义时可以不使用中括号、e2,默认步长为1。 1)Theestablishmentofmatrix Directinputmethod:Enclosethematrixelementsinsquarebrackets,andentertheelementsintheorderofthematrixrows。Theelementsinthesamerowareseparatedbyspacesorcommas,andtheelementsindifferentrowsareseparatedbysemicolons。 2)Usethecolonexpressiontocreatearowvector:e1:e2:e3 Amongthem,e1istheinitialvalue,e2isthestepsize,ande3thebracketsande2maynotbeusedinthedefinition,andthedefaultstepsizeis1。 3)用linspace函数产生行向量 linspace(a,b,n)。其中a和b是生成向量的第一个和最后一个元素,n是元素总数。linspace(a,b,n)与a:(ba)(n1):b等价。具体操作如下图所示: Usethelinspacefunctiontogeneratearowvector:linspace(a,b,n)。Whereaandbarethefirstandlastelementsofthegeneratedvector,andnisthetotalnumberofelements。linspace(a,b,n)isequivalenttoa:(ba)(n1):b。Thespecificoperationisshowninthefigurebelow: 4)特殊矩阵Specialmatrix 空矩阵〔〕:不包含任何元素,阶数为00。 产生特殊矩阵的函数:zeros(m,n)〔产生零矩阵〕。 Emptymatrix〔〕:doesnotcontainanyelements,andtheorderis00。 Afunctiontogenerateaspecialmatrix:zeros(m,n)〔generateazeromatrix〕。 ones〔产生全1矩阵〕、eye〔产生单位矩阵〕 ones〔generateall1matrix〕,eye〔generateidentitymatrix〕 rand〔产生0~1间均匀分布的随机矩阵〕、randn〔产生均值为0,方差为1的标准正态分布随机矩阵〕 rand〔Generateauniformlydistributedrandommatrixbetween0and1〕,randn〔generateastandardnormaldistributionrandommatrixwithameanvalueof0andavarianceof1〕 魔方矩阵:每行、每列及两条对角线上的元素和都相等;magic(n)生成一个n阶魔方阵。 具体操作如下图所示: Magiccubematrix:thesumoftheelementsineachrow,magic(n)generatesannordermagiccubematrix。 Thespecificoperationisshowninthefigurebelow: 5。matlab之线性规划函数 Linprog()对应的线性规划模型 minzcx Axb x0 〔x,fval〕linprog(c,A,b,Aeq,beq,lb,ub) 其中,x返回线性规划的最优解(列向量) fval返回目标函数最优值 c为目标函数系数(行列向量) A,b对应不等式约束Axb Aeq,beq对应等式约束AeqXbeq lb,ub指定x的范围,即lbxub,一般地,lb 为零向量,ub〔〕;b,beq,lb,ub均为列向量 举例:将下列模型转化为linprog格式 Minz3x1x24x3 sub。to6x13x25x345 3x14x25x330 x1,x2,x30 所以 c〔3;1;4〕;A〔6,3,5;3,4,5〕; b〔45;30〕;lbzeros(3,1); 〔x,fval〕linprog(c,A,b,〔〕,〔〕,lb,〔〕) 计算机返回结果:x(5;0;3),fval27 具体操作过程: ThelinearprogrammingmodelcorrespondingtoLinprog() minzcx Axb x0 〔x,fval〕linprog(c,A,b,Aeq,beq,lb,ub) Amongthem,xreturnstheoptimalsolutionofthelinearprogramming(columnvector)。fvalreturnstheoptimalvalueoftheobjectivefunction。cistheobjectivefunctioncoefficient(rowcolumnvector)。A,bcorrespondstotheinequalityconstraintAxb。 Aeq,beqcorrespondstotheequalityconstraintAeqXbeq。lb,ubspecifiestherangeofx,thatis,lbxub,generally,lbisazerovector,ub〔〕;b,beq,lb,ubareallcolumnvectors Example:Convertthefollowingmodeltolinprogformat Minz3x1x24x3 sub。to6x13x25x345 3x14x25x330 x1,x2,x30 so c〔3;1;4〕;A〔6,3,5;3,4,5〕; b〔45;30〕;lbzeros(3,1); 〔x,fval〕linprog(c,A,b,〔〕,〔〕,lb,〔〕) Thecomputerreturnstheresult:x(5;0;3),fval27 Specificoperationprocess: 今天的分享就到这里了。 如果您对今天的文章有独特的想法, 欢迎给我们留言, 让我们相约明天, 祝您今天过得开心快乐! Thatsitfortodayssharing。 Ifyouhaveauniqueideaabouttoday’sarticle, Welcometoleaveusamessage, Letusmeettomorrow, Iwishyouahappydaytoday! 参考资料:电子工业出版社MATLAB教程第3版 英文翻译:Google翻译 本文由LearningYard学苑整理并发出,如有侵权请在后台留言! LearningYard学苑 文案Qian 排版Qian 审核Tian