第3.3节 MATLAB的开发环境
- 格式:ppt
- 大小:26.00 KB
- 文档页数:4
§3 MATLAB的开发环境MATLAB的开发环境就是在使用MA TLAB的过程中可激活的,并且为用户使用提供支持的集成系统。
这里介绍几个比较重要的如:桌面平台系统、帮助系统和数据交换系统。
3.1 MATLAB桌面平台桌面平台是各桌面组件的展示平台,默认设置情况下的桌面平台包括6个窗口,具体如下:3.1.1 MATLAB主窗口MATLAB6比早期版本增加了一个主窗口。
该窗口不能进行任何计算任务的操作,只用来进行一些整体的环境参数的设置。
3.1.2命令窗口(Command Window)命令窗口是对MATLAB进行操作的主要载体,默认的情况下,启动MATLAB时就会打开命令窗口,显示形式如图1-1所示。
一般来说,MA TLAB的所有函数和命令都可以在命令窗口中执行。
在MA TLAB命令窗口中,命令的实现不仅可以由菜单操作来实现,也可以由命令行操作来执行,下面就详细介绍MALTAB命令行操作。
实际上,掌握MALAB命令行操作是走入MA TLAB世界的第一步,命令行操作实现了对程序设计而言简单而又重要的人机交互,通过对命令行操作,避免了编程序的麻烦,体现了MA TLAB所特有的灵活性。
例如:%在命令窗口中输入sin(pi/5),然后单击回车键,则会得到该表达式的值sin(pi/5)ans=0.5878由例可以看出,为求得表达式的值,只需按照MALAB语言规则将表达式输入即可,结果会自动返回,而不必像其他的程序设计语言那样,编制冗长的程序来执行。
当需要处理相当繁琐的计算时,可能在一行之内无法写完表达式,可以换行表示,此时需要使用续行符“……”否则MATLAB将只计算一行的值,而不理会该行是否已输入完毕。
例如:sin(1/9*pi)+sin(2/9*pi)+sin(3/9*pi)+……sin(4/9*pi)+sin(5/9*pi)+sin(6/9*pi)+……sin(7/9*pi)+sin(8/9*pi)+sin(9/9*pi)+……ans=5.6713使用续行符之后MA TLAB会自动将前一行保留而不加以计算,并与下一行衔接,等待完整输入后再计算整个输入的结果。
第一章MATLAB入门学习目标:1、了解MATLAB的发展历史,熟悉MATLAB操作环境。
2、掌握MATLAB变量、数值、数学函数输入输出的操作。
第一节 MATLAB操作环境一、 MATLAB的发展历史:MATLAB是矩阵(Matrix)和实验室(Laboratory)两个英文单词的前三个字母组合而成,由美国新墨西哥大学计算机系主任Cleve Moler博士首创,由美国Mathworks公司于1982年推出的一套高性能的集数值计算、符号运算和图形处理于一体的科学计算软件。
20世纪70年代Cleve Moler博士在讲授线性代数课时,发现用其它高级语言编程极不方便,为减轻学生负担,便构思用FORTRAN语言开发了MATLAB的第一代版本。
1983年Cleve Moler博士与工程师John Litlle、Steve Banger一起合作开发了MATLAB第二代版本,该版本全部用C语言编写,使MATLAB不仅具有数值计算功能,而且具有数据可视化功能。
1984年Cleve Moler博士和一批数学家、软件专家成立了Mathworks公司,专门从事MATLAB的开发,并把MATLAB推向市场。
从20世纪70年代最初的版本,分别推出基于Dos平台的第一代商业版本、基于平台的版本、基于Windows95、Windows98操作系统的版本、基于Windows98/2000/XP平台的版本、版本。
MATLAB历经几十年的不断完善和扩展,它不仅是线性代数、概率论及数理统计、自动控制理论、数字信号处理、动态系统仿真、数学建模、时间序列分析等课程的基本教学工具,而且走出学校,在工业生产、科学研究领域成为国际公认的具有高可靠性的高级计算机编程语言。
二、 MATLAB的主要特点:目前较为流行的数学软件有四种:MATLAB、Mathematica、Maple、MathCAD。
MATLAB自问世以来,一直以数值计算称雄,Mathematica和Maple在符号运算方面功能突出,MathCAD 因其可同时提供计算平台和写作平台而拥有很多用户。
MATLAB的开发环境和工具第三章MA TLAB的开发环境和工具3.1MA TLAB与其他软件的接口关系1.变量的存储和下载SaveLoad2.工作日志的记录Diary 文件名.txt…………Diary off3.通用命令库(general)(f)函数的管理命令,通用信息,工作空间管理,管理搜索路径,文件操作系统,命令窗控制,启动退出,公共信息,调试命令>> ver MATLAB和各工具箱的版本-------------------------------------------------------------------------------------MATLAB Version 7.0.0.19920 (R14)MATLAB License Number: 0Operating System: Microsoft Windows XP Version 5.1 (Build 2600: Service Pack 3)Java VM Version: Java 1.4.2 with Sun Microsystems Inc. Java HotSpot(TM) Client VM-------------------------------------------------------------------------------------MATLAB Version 7.0 (R14)Simulink Version 6.0 (R14)Aerospace Blockset Version 1.6 (R14)Bioinformatics Toolbox Version 1.1 (R14)CDMA Reference Blockset Version 1.1 (R14) Communications Blockset Version 3.0 (R14) Communications Toolbox Version 3.0(R14)Control System Toolbox Version 6.0 (R14)Curve Fitting T oolbox V ersion 1.1.1 (R14)Data Acquisition T oolbox V ersion 2.5 (R14)Database Toolbox Version 3.0 (R14)Datafeed Toolbox Version 1.5 (R14)Dials and Gauges Blockset V ersion 1.2 (R14)Embedded Target for Infineon C166 M... Version 1.1 (R14)Embedded Target for Motorola HC12 Version 1.1 (R14)Embedded Target for Motorola MPC555 Version 2.0 (R14)Embedded Target for OSEK VDX V ersion 1.1 (R14)Embedded Target for TI C2000 DSP(tm) V ersion 1.1 (R14)Embedded Target for TI C6000 DSP(tm) V ersion 2.1 (R14)Excel Link Version 2.2 (R14) Extended Symbolic Math Version 3.1 (R14) Filter Design HDL Coder Version 1.0 (R14) Filter Design Toolbox Version 3.0 (R14) Financial Derivatives Toolbox Version 3.0 (R14) Financial Time Series Toolbox Version 2.1 (R14) Financial Toolbox Version 2.4 (R14) Fixed-Income Toolbox Version 1.0.1 (R14) Fixed-Point Toolbox Version 1.0 (R14) Fuzzy Logic Toolbox Version 2.1.3 (R14) GARCH T oolbox V ersion 2.0.1 (R14) Genetic Algorithm Direct Search Too... Version 1.0.1 (R14)Image Acquisition Toolbox V ersion 1.5 (R14) Image Processing Toolbox V ersion 4.2 (R14) Instrument Control Toolbox Version 2.0 (R14)LMI Control T oolbox Version 1.0.9 (R14) Link for Code Composer Studio? Deve... V ersion 1.3.1 (R14)Link for ModelSim Version 1.1.1 (R14) MATLAB Builder for COM V ersion 1.1 (R14) MATLAB Builder for Excel Version 1.2 (R14) MATLAB Compiler Version 4.0 (R14) MATLAB Report Generator Version 2.0 (R14) MATLAB Web Server V ersion 1.2.3 (R14)Mapping Toolbox Version 2.0.2 (R14) Model Predictive Control Toolbox Version 2.0 (R14) Model-Based Calibration Toolbox Version 2.1 (R14)Mu-Analysis and Synthesis T oolbox Version 3.0.8 (R14) Neural Network Toolbox Version 4.0.3 (R14) OPC Toolbox Version 1.0 (R14) Optimization Toolbox Version 3.0 (R14) Partial Differential Equation Toolbox Version 1.0.5 (R14)RF Blockset Version 1.0 (R14) RF Toolbox Version 1.0 (R14) Real-Time Windows Target Version 2.5 (R14) Real-Time Workshop Version 6.0 (R14) Real-Time Workshop Embedded Coder Version 4.0 (R14) Robust Control Toolbox Version 2.0.10 (R14) Signal Processing Blockset Version 6.0 (R14) Signal Processing Toolbox Version 6.2 (R14) SimMechanics Version 2.2 (R14) SimPowerSystems Version 3.1 (R14) Simulink Accelerator V ersion 6.0 (R14) Simulink Control Design V ersion 1.0 (R14) Simulink Fixed Point V ersion 5.0 (R14)Simulink Parameter Estimation Version 1.0 (R14) Simulink Report Generator Version 2.0 (R14) Simulink Response Optimization Version 2.0 (R14) Simulink Verification and Validation Version 1.0 (R14) Spline T oolbox Version 3.2.1 (R14) Stateflow Version 6.0 (R14) Stateflow Coder Version 6.0 (R14) Statistics Toolbox Version 5.0 (R14) Symbolic Math Toolbox Version 3.1 (R14) System Identification Toolbox Version 6.0.1 (R14) Virtual Reality Toolbox Version 4.0 (R14) Wavelet Toolbox Version 3.0 (R14) xPC Target Version 2.5 (R14) xPC Target Embedded Option Version 2.5 (R14) >>>> matlabrcTo get started, select MA TLAB Help or Demos from the Help menu.>> startupUndefined function or variable 'startup'. >> what>> what MA TLABMATLAB not found.>> inmem 列出内存中的函数ans ='matlabrc''pathdef''userpath''ispc''general\private\openm''filesep''pwd''usejava''hgrc''opaque.char''colordef''whitebg''isunix''jet''gcf''brighten''initprefs''findallwinclasses''initdesktoputils''path''mdbstatus''lasterror''close''graphics\private\clo''graphics\private\start''graphics\private\setup''graphics\private\setset''graphics\private\restoreui''graphics\private\restorepointers''graphics\private\restorehg''graphics\private\restore''graphics\private\render''graphics\private\preparepointers''graphics\private\preparehg''graphics\private\prepare''graphics\private\positions''graphics\private\prepareui''graphics\private\noselection''graphics\private\name''graphics\private\validate''graphics\private\isslhandle''graphics\private\isfigure''graphics\private\inputcheck''graphics\private\getget''graphics\private\fireprintbehavior' 'graphics\private\finish' 'graphics\private\enabledberror''graphics\private\disabledberror' 'graphics\private\blt''gcbf''setdiff''iscell''ismember''opaque.double''repmat''sortrows''lineseries''getappdata''ancestor''newplot''gca''ishghandle''isappdata''findall''cell.sort''isfield''filemenufcn''fullfile''allchild''hgexport''fileparts''uiopen''gcbo''printtables''iscellstr''int2str''print''fgetl''prefdir''printjob''printopt''ispuma''cell.strmatch''strmatch''getprinttemplate' 'slinstallprefs''simulink\private\configSetPref' 'simulinkrc' 'getActiveConfigSet''slprivate''noanimate''hggetbehavior''isstruct''imwrite''num2str''strvcat''imagesci\private\isxwd''imagesci\private\istif''imagesci\private\isras''imagesci\private\isppm''imagesci\private\ispnm''imagesci\private\ispng''imagesci\private\ispgm''imagesci\private\ispcx''imagesci\private\ispbm''imagesci\private\isjpg''imagesci\private\isico''imagesci\private\isgif''imagesci\private\isfits''imagesci\private\iscur''imagesci\private\isbmp''imagesci\private\ishdf''imagesci\private\imftype''imagesci\private\writejpg''imformats''cellstr''closereq''cell.strcat''edit''hdfh''open''finfo''strtok''imfinfo''javachk''workspacefunc''mat2str''ver''strread''pathsep''fliplr''prepender'>> readme 显示readme文件Warning: Function call readme invokes inexact match C:\MATLAB7\toolbox\webserver\webserver\Readme.m.README file for the MA TLAB Web Server.This file contains important information about installingand running MATLAB Web Server Version 1.2.1. Pleaseread it thoroughly before attempting to work with this product.PLATFORM SUPPORTMATLAB Web Server Version 1.2.1 runs with Release 12.1 of MATLAB/Simulink. It runs only on Microsoft Windows NT 4.0, Sun Solaris, and Linux.ADMINISTRATIVE PRIVILEGES REQUIRED FOR INSTALLATIONSystem Administration privileges are required for theinstallation of the MA TLAB Web Server.X WINDOWS RECOMMENDED FOR GRAPHICS ON UNIXMATLAB makes use of X Windows on Unix to render jpegfiles efficiently. While the matlabserver componentof this product can generate graphics without X Windows, the best efficiency comes from the use of X Windows.X Windows must be running before the matlabserveris started.NOTE: The notation represents the MA TLABroot directory, the directory where MATLAB is installedon your system.CHANGES FROM PREVIOUS RELEASES1. The server can now be configured to accept connections onlyfrom specified nodes. Create a file called hosts.conf in the/webserver directory. List host names, one on each line, from which you want connections to be accepted. For example, /doc/9315488969.html,/doc/9315488969.html,Connection requests from any other host will be rejected.2. The htmlrep function now supports a fourth optional argument. Ifyou include 'noheader' in the string of this argument, the HTTPheader, "Content-type: text/html\n\n" will not be included in the output. (Note that you must supply an empty string as the third argument if you do not want the output to also be written to a file.)3. The distribution now includes all the CGI clients (matweb programson supported Unix platforms and matweb.exe on NT). Now there is more flexibility for running the client. Note also that a MATLABlicense is not required to run the matweb client.WEB SERVER SOFTWARE REQUIREDYou need to install Web server software (HTTP Daemon software [HTTPD]) on the system where MATLAB is running or on a machine that has network access to the machine where MA TLAB is running. There are numerous sources for obtaining this software,including:Pre-installed Microsoft Peer Networking Services on your PC.Netscape Enterprise Server, available by purchase fromNetscape Communications, Inc.Free distribution over the Internet (e.g., Apache:/doc/9315488969.html,)INSTALLATION OF VERSION 1.2.1The installation of this release requires some additionalsteps beyond the automated installation.Run through the normal installation process, installingMA TLAB Web Server as part of MATLAB/Simulink installationprocess.Solaris only (test server interactively and start onsystem boot):1. Create the file matlabserver.conf by running thescript /webserver/webconf. Use thisscript configurator to specify the number ofsimultaneous MATLABs to run, non-default TCP/IPport, etc. Use the "-h" option with this scriptto see the various options.2. Run startup script /webserver/webstartto start the server interactively to test.3. /webserver/webstat will display thestatus of the matlabserver.4. /webserver/webdown will take down the matlabserver.5. /webserver/webboot is run during thesystem startup process to bring up the serverat system boot time.6. Create the following symbolic links and file while logged in as root (superuser):ln -s /webserver/webboot /etc/webboot_TMW5ln -s /webserver/webdown /etc/webdown_TMW5 Note: Add the -c configuration file option to webboot and webdown if the matlabserver.conf file is not in/webserver or in the directory where thescript is located.cp -p /webserver/rc.web.sol2 /etc/init.d/webserver (Edit the file /etc/init.d/webserver to remove the comment characters from the code that starts X Windows if you want to start X Windows automatically at this point during the system boot.)7. Add the startup to the system startup by creating a symbolic link:cd /etc/rc3.dln -s ../init.d/webserver S17webserver8. [optional] In /webserver/rc.web.ARCH thereis a section that will attempt to start the X Windows system. You can remove the comment character from thiscode to start X Windows unless you or the system administrator start it somewhere else prior to the MATLAB Web Server startup script/webserver/webboot.9. Reboot the system.All Platforms:A. Modify the file matweb.conf in the demo directory,/matlab/toolbox/webserver/wsdemos. Replacewith the name of the machinewhere MA TLAB is installed (and the matlabserver program is running). Replace with the nameof the directory where MATLAB is installed. [webmagic]mlserver=[webpeaks]mlserver=mldir=/toolbox/webserver/wsdemos [webstockrnd]mlserver=mldir=/toolbox/webserver/wsdemos[players]mlserver=mldir=/toolbox/webserver/wsdemosB. Create the following three aliases for your HTTPD (Web server) and point them all to the demos directory,/toolbox/webserver/wsdemos:1. the home or default directory2. /cgi-bin3. /iconsIf your application produces graphic (jpeg)files, you will need to allow MATLAB to write into into an aliased location in the file system thatthe HTTPD can access. For example, you canuse the /icons alias to accomplish this.The mldir entry associated with the applicationin matweb.conf provides a way for MATLAB to create files in the right place.NOTE: If you do not have the ability to set up or change these aliases, it will be necessary to put copies of some files in locations where the HTTPD can find them:4. matweb (matweb.exe on NT), which can be found in /webserver/bin/sol2 on Solaris,in /webserver/bin/glnx86 on Linux,or in /webserver/bin/win32 on NT, must be copied to the directory that is aliased by/cgi-bin or equivalent.5. matweb.conf in/toolbox/webserver/wsdemosmust also be copied to the directory that is aliased by /cgi-bin or equivalent. See the documentation for more specifics on thispoint, especially if programmers do not havewrite access to this directory.6. All demo HTML files in/toolbox/webserver/wsdemosmust be copied to the directory wherethe HTTPD keeps all HTML files (oftenreferred to as the home or default alias).Note that when aliases are different fromthose provided in the demo HTML files, youwill have to make the corresponding changesin those HTML files.C. To run the demonstration programs when thedefault or home alias points to/toolbox/webserver/wsdemos directory,start your web browser and enter the URL:http:///index.html for thecurrent list of demonstration applications.REMOVING MATLABSERVER FROM THE WINDOWS NT REGISTRYTo remove the matlabserver (MATLAB Server) entry from the NT Registry, open a command window, set the default directory (cd)to /webserver/bin/win32, and type "matlabserver -remove".3.日期和时间如何确定做某种运算所用的时间(1)t0=clock;y=inv(rand (100,100));etime(clock,t0)ans =0.1410%etime 所经历的时间(2) %cputime 以秒计算的cpu时间t=cputime ;y=inv(rand(100,100));cputime-tans =(3) %tic,toc 秒表计时器的启动和开始tic;y=inv(rand(100,100));tocElapsed time is 0.016000 seconds.4.不退出MATLAB 环境运行其他软件(1)‘!’启动DOS系统3.1.2 与文字处理系统Winword的关系1.利用剪贴板进行交互2.文本编辑器的使用3.notebook的使用启动步骤:(1)notebook –setup(2)3(3)Notebook3.1.3 图形文件的转储3.1.4 低层输入输出函数库(1)底层输入输出函数库命令(iofun)(j)文件开闭及I/O,文件定位,字符串及文件名处理文件输入输出,图像声音I/O(2)客户机函数库(dde)(g)动态数据交换3.1.5 与C和FORTRAN子程序的动态链接3.2MARLAB的文件管理系统3.2.1安装后的MATLAB文件管理系统3.2.2 MATLAB自身的用户文件格式(1)程序文件.m(2)数据文件.mat(3) MA TLAB的可执行命令.mex(4) simulink工具建模,.mdl和仿真文件(后缀.s)3.2.4 与目录和搜索有关的命令dircddeletewhat[子目录]which[文件名]>> which pathC:\MATLAB7\toolbox\matlab\general\path.mlookfor[字符串]CLABEL Contour plot elevation labels.CONTOUR Contour plot.CONTOUR3 3-D contour plot.CONTOURC Contour computation.CONTOURF Filled contour plot.CONTOURS Contouring over non-rectangular surface. CONTOURSLICE Contours in slice planes. EZCONTOUR Easy to use contour plotter. EZCONTOURF Easy to use filled contour plotter. EZMESHC Easy to use combination mesh/contour plotter. EZSURFC Easy to use combination surf/contour plotter. MESHC Combination mesh/contour plot.SURFC Combination surf/contour plot.3.3MA TLAB的开发环境3.3.1桌面系统的内容command window 命令窗口command history 历史命令窗口current directory brower 当前路径浏览器help browser 帮助浏览器workspace browser 工作空间浏览器array editor 数组编辑器editor debugger 程序编辑调试器3.3.2 桌面命令菜单简介3.3.3 MATLAB 的用户界面help indexangle。