资源预览内容
第1页 / 共40页
第2页 / 共40页
第3页 / 共40页
第4页 / 共40页
第5页 / 共40页
第6页 / 共40页
第7页 / 共40页
第8页 / 共40页
第9页 / 共40页
第10页 / 共40页
亲,该文档总共40页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
Matlab Programming for EngineersRoom 414, EE/AC, SYSUEmails: ynzhangieee.org, zhynongmail.sysu.edu.cnYunong Zhang (张雨浓)http:/sist.sysu.edu.cn/teacher_info.aspx?id=155What is Matlab?Why do we learn Matlab?How do we learn Matlab?IntroductionA Brief History of MatlabnEngineering and scientific applications involve a lot of number crunching.nFor many years, the main language for this was FORTRAN - first high level programming language, and especially designed for numerical computing.nHeres a Fortran code to solve ax2 + b x + c = 0:C Solve a quadratic equation (this is a comment). DESC = B*B - 4*A*C IF ( DESC .LT. 0.0 ) GOTO 10 DESC = SQRT(DESC) X1 = (-B + DESC)/(2.0*A) X2 = (-B - DESC)/(2.0*A) WRITE(6,*) SOLUTIONS ARE ,X1, AND , X2 RETURN 10 WRITE(6,*) EQUATION HAS COMPLEX ROOTS RETURNProblems using FORTRANNumber crunching on a computer can be tricky.Problems that occur are:nloss of precision and inaccurate results:X = 0.1Y = 1.0 - 10*X Y should equal 0, but probably does not! nunderflow and overflow: X = 1.0E20, X*X - too big!nefficient coding of algorithms not always obvious DO 10 N=1,100000 10 Y(N) = SQRT(2.0)*X(N) which crossC:MATLAB6p5toolboxmatlabspecfuncross.mGetting HelpnGet help in three ways in MatlabnClick Toolbar icon to start the Help BrowsernType help specificfunction in Command Window help sin SIN Sine. SIN(X) is the sine of the elements of X.nType lookfor specificfunction in Command WindowGetting Help (cont.)nHelp Browser: Allow full access to the entire Matlab documentation setnhelp functionname: You must know the name of the function to get help about itnlookfor functionname: Search for a given string in the first comment line of every Matlab function, and display all matches help a a.m not found. lookfor aADDPATH Add directory to search path.BINPATCH Patch binary file.CD Change current working directory.CLEAR Clear variables and functions from memory.DATATIPINFO Produce a short description of a variable.DBCLEAR Remove breakpoint.DBDOWN Change local workspace context.DBSTACK Display function call stack.DBSTATUS List all the breakpoints.
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号