MATLAB实习报告
- 格式:pdf
- 大小:627.31 KB
- 文档页数:14
matlab实训心得体会(通用23篇)matlab实训篇1自己刚刚接触matlab有半个学期的时间,说实话我现在对MATLAB还是摸不着头脑,一方面是自己接触的时间太短,另一方面,就是自己在上机方面投入的时间有限,实践比较少。
现在,我对MATLAB的印象仅仅在解决习题和绘制图形上,但是我很喜欢MATLAB的简单的语法,易于绘制图形,编程也非常容易, 并且具有功能强大的开放式的toolbox。
因此,尽管我一直没有这方面的应用,但是我还是对它非常感兴趣,自己正打算暑假好好研究研究MATLAB。
下面是我学习MATLAB在理论和实践方面的一点心得与体会,可能有些地方自己理解的不是很正确,但是随着学习的深入,我想我可以发现自己的错误所在。
首先我想说的是,在理论方面,在学习MATLAB过程中,我感觉到它和c语言有许多相似之处,他有c语言的特征,但是比c语言编程计算更加简单,适合于复杂的数学运算。
但是MATLAB跟其他语言也有着很大的不同。
现在用的比较多的编程语言,除了MATLAB就应该是c、c++、VHDL,VB和Delphi也接触过,如果自己抱着“把其他语言的思想运用在MATLAB里面”的话,那么我想,即使程序运行不出错,也很难把握MATLAB的精髓,也就很难发挥MATLAB的作用了。
众所周知MATLAB是一个基于矩阵运算的软件,但是,真正在运用的时候,特别是在编程的时候,许多人往往没有注意到这个问题。
在使用MATLAB时,受到了其他编程习惯的影响,特别是经常使用的C语言。
因此,在MATLAB编程时,for循环(包括while循环)到处都是。
.这不仅是没有发挥MATLAB所长,还浪费了宝贵的时间。
我这里想说的一点是,往往在初始化矩阵的时候注意到这个问题,懂得了使用矩阵而不是循环来赋值,但是,在其他环节上,就很容易疏忽,或者说,仍然没有摆脱C++、C的思想。
MATLAB博大精深,涉及的内容很多,所以,我认为不要试图掌握MATLAB的每一个功能,熟悉和你专业最相关的部分就可以了,这也是老师在课堂上经常说的。
matlab_实习报告在大学的学习生涯中,实习是一个非常重要的环节,它能够让我们将理论知识与实际应用相结合,提升自己的专业技能和综合素质。
本次实习,我选择了使用 MATLAB 这个强大的工具进行实践操作,通过一段时间的学习和实践,我收获颇丰。
一、实习目的本次实习的主要目的是深入了解和掌握MATLAB 软件的使用方法,能够运用其解决实际问题,并提高自己的编程能力和逻辑思维能力。
同时,通过实际项目的操作,培养自己的团队协作精神和解决问题的能力,为今后的学习和工作打下坚实的基础。
二、实习单位及岗位介绍我实习的单位是_____,在实习期间,我主要负责利用 MATLAB 进行数据分析和算法实现的相关工作。
三、实习内容及过程(一)基础学习在实习的初期,我首先对 MATLAB 的基本语法和操作进行了系统的学习。
了解了变量的定义、数据类型、矩阵运算、函数的编写等基础知识。
通过大量的练习和实例,我逐渐熟悉了 MATLAB 的编程环境,能够熟练地编写简单的程序。
例如,在学习矩阵运算时,我通过编写程序实现了矩阵的加法、乘法、求逆等操作,深刻理解了矩阵运算在数学和工程中的重要应用。
(二)项目实践在掌握了基础知识后,我开始参与实际的项目。
其中一个项目是对一组数据进行分析和处理,以提取有用的信息。
首先,我使用MATLAB 读取数据文件,并对数据进行预处理,包括去除噪声、缺失值处理等。
然后,运用统计学方法对数据进行分析,计算均值、方差、相关性等统计量。
最后,通过绘图函数将分析结果以直观的图表形式展示出来,以便更好地理解数据的特征和趋势。
在这个过程中,我遇到了很多问题。
例如,数据的格式不一致导致读取错误,算法的复杂度过高导致运行时间过长等。
通过查阅资料、请教同事和不断地调试,我最终解决了这些问题,顺利完成了项目任务。
(三)算法实现除了数据分析,我还参与了算法的实现工作。
在一个图像识别的项目中,需要使用机器学习算法对图像进行分类。
竭诚为您提供优质文档/双击可除matlab实践报告篇一:matlab实习报告mATLAb实习报告姓名:吴涛专业:电子信息工程班级学号:信息(2)班20XX1605010230指导教师:宋艳霞钱云实习时间:20XX,5,13至20XX,5,17目录:一:实习目的 (3)二:实习任务...........................三:实习要求...........................四:实习目的...........................五:实习体会...........................一:实习目的熟悉matlab的软件环境熟悉matlab的基本使用方法二:实习任务1.掌握matlab语言的基本语法规则及基本操作命令的使用。
2.熟悉运用matlab的数组,矩阵运算,数学运算的运算方法。
3.熟悉matlab的字符串,单元数组。
4.熟悉matlab的程序设计。
5.熟悉matlab的符号计算功能。
6.熟悉matlab的绘图及句柄图形。
7.6熟悉matlab的guI设计。
三:实习要求1.每次上机要签到,记录。
2.做的题目要在上机结束后以电子版和woRD文档形式交给指定负责人。
3.认真做一份实习总结报告。
四:实习内容共六题第1题:求a和b的和。
代码:a=[1,2,3]b=[4,5,6]s=a+b结果:s=579第2题:求a和b的差。
代码:a=[4,5,6]b=[1,2(:matlab实践报告),3]h=a-b结果:h=333第3题:求下列方程组的解。
6x1+3x2+4x3=3-2x1+5x2+7x3=-48x2-4x2-3x3=-7代码:A=[6,3,4;-2,5,7;8,-4,-3] b=[3;-4;-7]a=A\b结果:a=0.60007.0000-5.4000第4题:用for语句求三角函数表。
代码:forx=0:0.1:pi/4disp([x,sin(x),cos(x),tan(x)]),en d结果:00100.10000.09980.99500.10030.20000.19870.98010.20270.30000.29550.95530.30930.40000.38940.92110.4228篇二:matlab课程实践报告mATLAb实践》课程设计学生姓名:林淑真学号:110900824专业班级:通信工程四班指导教师:郑晓明二○一二年六月十五日《目录1.设计目的.........................................................22.题目分析.........................................................23.总体设计.........................................................34.具体设计.........................................................35.结果分析.........................................................226.心得体会.........................................................237.参考书目.........................................................238.附录 (24)1、设计目的综合运用mATLAb工具箱实现图像处理的guI程序设计。
matlab实习总结.(大全5篇)第一篇:matlab实习总结.MATLAB和Mathematica、Maple并称为三大数学软件。
它在数学类科技应用软件中在数值计算方面首屈一指。
MATLAB可以进行矩阵运算、绘制函数和数据、实现算法、创建用户界面、连 matlab开发工作界面接其他编程语言的程序等,主要应用于工程计算、控制设计、信号处理与通讯、图像处理、信号检测、金融建模设计与分析等领域。
MATLAB的基本数据单位是矩阵,它的指令表达式与数学、工程中常用的形式十分相似,故用MATLAB来解算问题要比用C,FORTRAN等语言完成相同的事情简捷得多,并且MATLAB也吸收了像Maple等软件的优点,使MATLAB成为一个强大的数学软件。
在新的版本中也加入了对C,FORTRAN,C++,JAVA的支持。
可以直接调用,用户也可以将自己编写的实用程序导入到MATLAB函数库中方便自己以后调用,此外许多的MATLAB爱好者都编写了一些经典的程序,用户可以直接进行下载就可以用Matlab是一个强大的数学工具,它的应用广泛,涉及到各个领域.它使用起来十分方便,不用麻烦去定义变量.它的绘图能力很强,甚至可以模拟出三维视图.矩阵是它应用的核心,许多工程繁琐的运算都需要靠矩阵来化简,这正是它的生命力所在.但是,他的函数很多,开始学时记的比较痛苦,我已经深深感觉到了.不过看多了也就熟了,感觉和学五笔差不多.它的语法简单,像我学过C语言的学起来还是蛮容易的.它的数组定义十分符合自然,是从1开始的,数组元素的调用也很接近数学的表达.此外,函数的名字也很符合英文规则,反正我用得很开心就是了.通过学习matlab,我又一次锻炼了自己的思维.它学起来得心应手也让我明白了学习一门语言(c语言对学习其他语言的帮助指导作用.同时,它也加强了我理论联系实际的能力.这是一个专业课的基础工具,学好它是必要的.在第一章中,讲的是一些matlab的入门技术,除了一些基本操作与介绍之外,还初步认识了简单指令的编制,认识了一些matlab 的特殊符号,例如运算用到的加减乘除。
MATLAB_实习报告范文大全第一篇:MATLAB_实习报告实习报告实习题目:专业:学号:的设计与绘图MATLAB 一.概述MATLAB 作为一种高级科学计算软件,是进行算法开发、数据可视化、数据分析以及数值计算的交互式应用开发环境。
世界上许许多多的科研工作者都在使用 MATLAB 产品来加快他们的科研进程,缩短数据分析和算法开发的时间,研发出更加先进的产品和技术。
二.实验目的1.进一步熟悉MATLAB的软件环境和基本使用方法;2.巩固运用MATLAB、矩阵运算、多项式运算、字符串、单元数组、符号计算功能、绘图及句柄图形及它们的命令语句;3.学习和巩固数字图形图像处理在MATLAB中的知识和运用;4.培养我们独立自学、设计和撰写实验报告的能力;5.通过对MATLAB的进一步学习,是我们加深所学内容的认识,理解,掌握,能把所学知识运用到实际工作中;三.实习日记1.熟悉MATLAB的软件环境和基本使用方法(第一周)MATLAB的语言的基本功能和特点:它是一种高级科学计算语言,相对于传统的C、C++ 或者FORTRAN 语言,MATLAB 提供了高效快速解决各种科学计算问题的方法。
它具有数学计算、开发工具、数据的可视化、交互式编辑创建图形、集成的算法开发编程语言和环境、图形用户界面开发环境——GUIDE、开放性、可扩展性强、专业应用工具箱等强大的功能。
具有易于学习、使用方便、支持多种操作系统、丰富的内部函数、强大的图形和符号功能等优点。
路径设置:除 MATLAB 默认的搜索路径外,用户可以设置搜索路径。
设置方法为:选择 MATLAB 窗口中的 File | Set Path 命令,进入路径搜索对话框。
MATLAB 的搜索顺序:当在命令窗口中或者一个 M 文件中输入一个元素名时,MATLAB 按照下面的顺序搜索该元素的意义,以元素foo 为例:1)查找工作区中是否存在名为 foo 的变量; 2)在当前路径中查找是否存在名 foo.m 的文件;3)按照顺序查找搜索路径中是否存在该文件。
初识MATLAB的实验报告1. 引言MATLAB(Matrix Laboratory)是一种高级的技术计算环境和编程语言。
它具有强大的矩阵计算能力和丰富的科学和工程绘图功能,被广泛应用于各个领域的科研与工程实践中。
本实验旨在初步了解MATLAB的基本语法和功能,通过实际操作加深对MATLAB编程的理解。
2. 实验目的1. 掌握MATLAB的安装和基本使用方法;2. 学习MATLAB中的常用数学函数和操作;3. 了解MATLAB绘图功能并能够绘制简单的图形。
3. 实验步骤3.1 MATLAB安装首先,在官方网站(3.2 MATLAB入门3.2.1 MATLAB语法MATLAB的语法类似于其他常见的编程语言,每个语句以分号结尾。
在MATLAB 中,可以直接进行基本的数学运算,例如加减乘除、指数、对数等。
通过以下代码可以计算两个变量的和并将结果打印出来:matlaba = 10;b = 20;sum = a + b;disp(sum);3.2.2 MATLAB变量在MATLAB中,可以创建和操作各种类型的变量,例如数值、字符串、矩阵等。
以下代码演示了如何创建一个矩阵:matlabmatrix = [1, 2, 3; 4, 5, 6; 7, 8, 9];disp(matrix);3.2.3 MATLAB函数MATLAB提供了许多内置的数学函数,可以直接调用。
以下代码演示了如何计算正弦函数值并打印结果:matlabx = pi/4;y = sin(x);disp(y);3.3 MATLAB绘图MATLAB具有强大的绘图功能,可以绘制各种图形,如曲线、散点图、柱状图等。
以下代码演示了如何绘制一个简单的正弦曲线:matlabx = linspace(0, 2*pi, 100);y = sin(x);plot(x, y);xlabel('x');ylabel('y');title('Sine Curve');4. 实验结果与分析在完成上述实验步骤后,我们成功安装了MATLAB,并学习了基本的语法、变量和函数的使用方法。
M AT L A B语言编程实训报告题目MATLAB在信号与系统中的应用年级2008 专业电子信息工程目录第一章绪论 (2)1.1 本设计课题目的及意义, 重点解决的问题 (2)1.1.1 MATLAB在信号与系统中应用的目的及意义 (2)1.1.2 重点解决的问题 (2)1.2 课题的社会和技术背景 (2)1.3 实现的具体功能 (3)第二章课题的基本概念和原理 (4)2.1 MATLAB的概念 (4)2.2 信号与系统的概念 (4)2.3 信号与系统分析的基本内容与方法 (5)2.4 离散系统的基本概念 (6)2.5连续系统模型及表示 (6)第三章系统设计和实现 (7)3.1采用的软件及开发平台 (7)3.1.1系统设计软件 (7)3.1.2开发平台和编程环境 (7)3.2系统的详细设计 (8)3.2.1建模 (8)3.2.2解决方法 (9)3.3系统设计的亮点 (9)第四章结束语 (10)参考文献 (10)第一章绪论1.1 本设计课题目的及意义, 重点解决的问题1.1.1 MATLAB在信号与系统中应用的目的及意义MATLAB在信号与系统中应用能够让学生熟悉MATLAB软件平台、工具箱、高效的数值计算及符号计算功能。
熟悉MATLAB软件的信号处理编程方法和结果的可视化。
了解数字信号处理的计算机仿真方法。
进一步加深对信号与系统的基本原理、方法及应用的理解。
MATLAB软件具有强大的数值分析和计算结果可视化的功能.运用MATLAB软件,通过一个应用实例,将信号与系统课程的理论与实践教学有机地结合,有效地解决了教学中的难点问题,说明了MATLAB软件在信号与系统课程的实践教学中具有重要的实际意义1.1.2 重点解决的问题matlab的基本使用方法, matlab的预定义函数, 如何用matlab绘图, 如何在matlab中编程, 基于matlab的矩阵运算、符号运算、数值分析等。
1.2 课题的社会和技术背景长期以来, “信号与系统”课程一直采用黑板式的单一的教学方式, 学生仅依靠做习题来巩固和理解教学内容, 对课程中大量的应用性较强的内容不能实际动手设计、调试、分析, 严重影响和制约了教学效果。
MATLAB实验报告(8个实验)四川师范大学MATLAB语言实验报告1系级班年月日实验名称:Intro, Expressions, Commands姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB program development environment and to develop your first programs in this environment.2Using MATLAB2.1Starting MATLABLogon to your computer and start MATLAB by double-clicking on the icon on the desktop or by using the Start Programs menu. MATLAB Desktop window will appear on the screen.The desktop consists of several sub-windows. The most important ones are:●Command Window (on the right side of the Desktop) is used to do calculations,enter variables and run built-in and your own functions.●Workspace (on the upper left side) consists of the set of variables (arrays) createdduring the current MATLAB session and stored in memory.●Command History (on the lower left side) logs commands entered in theCommand Window. You can use this window to view previously run statements, and copy and execute selected statements.You can switch between the Launch Pad window and the Workspace window using the menu tabs under the sub-windowon the upper left side. Similarly, you can switch between the Command History and Current Directory windows using the menu tabs under the sub-window on the lower left side.2.2Executing CommandsYou can type MATLAB commands at the command prompt “>>” on the Command Window.For example, you can type the formula cos(π/6)2sin(3π/8) as >>(cos(pi/6) ^ 2) * (sin(3 * pi/8))Try this command. After you finish typing, press enter. The command will be interpreted and the result will be displayed on the Command Window.Try the following by observing how the Workspace window changes:>> a = 2; (M ake note of the us age of “;”)>> b = 3;>> c = a ^ 4 ? b ? 5 + pi ^3You can see the variables a, b and c with their types and sizes on the Workspacewindow, and can see the commands on the Command History window.Spend a few minutes to practice defining array variables (i.e. vectors and matrices)usingthe square bracket (“[ ]”) and colon (“:”) operators, and zeros() and ones() functions.>> ar =[ 1 2 3 4 5 ];>> br =[ 1 2 3 ;4 5 6 ];>> cr = [1 : 3 : 15];Set dr to ?rst 3 elements of ar.dr=ar(1:3);Set er to second row of br.er=br(2,:);Set ar to [dr er]. Find the number of elements of ar.ar=[dr er]; length(ar)2.3 Getting HelpThere are several ways to get help on commands and functions in MATLAB. First ofall you can use the Help menu. You can also use the “?” button. Try to findinformation on the plot function from the help index. Also try to get information onthe same function using the help command (i.e. type help plot). Finally, experimentwith the lookfor command. This command looks for other commands related to agiven keyword.2.4 Some Useful CommandsTry the following commands and observe their results:Which : Version and location infoClear : Clears the workspaceClc : Clears the command windowwho, whos : Lists content of the workspace3 ExercisesPlease solve the following problems in MATLAB. Do not forget to keep a diary ofyour commands and their outputs.(1) De?ne the variables x y and z as 7.6, 5.5 and 8.1, respective ly, and evaluate:578.422.52??? ??-x y xz(2) Compute the slope of the line that passes through thepoints (1,-2) and(5,8).(3) Quiz 1.1: 5(4)1.6 Exercises: 1.1, 1.4(5)2.15 Exercises: 2.6, 2.9, 2.114Quitting MATLABTyping quit on the command window will close the program. Do not forget to send your diary file and M-file to your TA.Do not forget to delete your ?les from the hard disk of the PC you used in the lab at the end of the lab session.四川师范大学MATLAB语言实验报告2系级班年月日实验名称:Programming, Relational and Logical Expressions 姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB script files (M-files), subarrays, relational and logical operators.2Script FilesScript files are collections of MATLAB statements that are stored in a file. Instead of typing commands directly in the Command Window, a series of commands may be placed into a file and the entire file may be executed by typing its name in the Command Window. Such files are called script files that are also known as M-files because they have an extension of .m. When a script file is executed, the result is the same as it would be if all of the commands had been typed directly into the Command Window. All commands and script files executed in the Command Window share a common workspace, so they can all share variables in the workspace. Note that if two script files are executed successively, the second script file can use the variables created by the first script file. In this way, script files can communicate with other script files through the data left behindin the workspace. An Edit Window is used to create new M-files or to modify existing ones. The Edit Window is a programming text editor, with the features of MATLAB language highlighted in different colors. You can create a new M-file with the File/New/M-file selection and you can open an existing M-file with the File/Open selection from the desktop menu of MATLAB.(1)Create a new working directory under the current directory and change the currentdirectory to …TA?s suggest?.3SubarraysIt is possible to select and use subsets of MATLAB arrays. To select a subset of an array, just include a list of the elements to be selected in the parentheses after the array name. MATLAB has a special function named end that is used to create arraysubscripts. The end function always returns the highest value taken on by a givensubscript. It is also possible to use subarrays on the left-hand side of an assignmentstatement to change only some of the values in an array. If values are assigned to asubarray, only those values are changed but if values are assigned to an array, theentire contents of the array are replaced by the new values.(1) Define the following 5 x 5 array arr1 in MATLAB.----=2274235421209518171651413215111012844563311arr(2) Write a MATLAB statement to select a subset of arr1 and return the subarraycontaining the values as shown.=22745456311arrarr11=arr1([1,5],[2 4 5]);(3) Write two MATLAB statements to select the last row and last column of arr1,separately.arr12=arr1(5,:);或arr12=arr1(end,:); arr13=arr1(:,end);或arr13=arr1(:,5);(4) Write MATLAB statements to obtain the following array from arr1.-=2257462335432112arrarr2=arr1([1 5],:)';4 Relational and Logical OperatorsRelational and logical operators are the two types of operators that produce true/falseresults in MATLAB programs. MATLAB interprets a zero value as false and anynonzero value as true. Relational operators ( ==, =,>,>=,<,<=) are operators with twooperands that produce either a true (1) or a false (0) result, depending on the values ofthe operands. Relational operators can be used to compare a scalar value with an array.They can also be used to compare two arrays or two strings only if they have the samesize. Be careful not to confuse the equivalence relational operator ( == ) with theassignment operator ( = ). Logic operators ( &, |, xor, ~ ) are operators with one ortwo operands that yield a logical result such as 0 or 1. There are three binary logicoperators: AND (& ), OR ( |), and exclusive OR ( xor ); and oneunary operator: NOT( ~). In the hierarchy of operations, logic operators are evaluated after allarithmetic and relational operators have been evaluated. The operator is evaluatedbefore other logic operators.(1) Define the following 4 x 5 array arr4 in MATLAB.------=212343212343212543214arr(2) Write an expression using arr4 and a relational operator to produce the followingresult.=110001110011110111115arrarr5=arr4>0;(3) Write an expression using arr4 and a relational operator to produce the followingresult.=010000010000010000016arrarr6=arr4==1;(4) Write a MATLAB program which will generate an (n-1)x(n-1) matrix from agiven nxn matrix which will be equal to given matrix with first row and firstcolumn deleted.arr44=rand(5); arr444=arr35(2:end,2:end);(5) Generalize your program above so that the program should ask the row andcolumn numbers to be deleted and then generate new (n-1)x(n-1) matrix.n=input('input n:');matrixn=rand(n)delrow=input('input row numbers to be deleted:');delcolumn=input('input column numbers to be deleted:');matrixn_1=matrixn([1:delrow-1 delrow+1:end], [1:delcolumn-1 delcolumn+1:end])(6) Quiz 3.1 (P88)5 Quitting MATLABTyping quit on the command window will close the program. Do not forget to sendyour diary file and M-file to your TA.Do not forget to delete your files from the hard disk of the PC you used in the lab atthe end of the lab session.四川师范大学MATLAB 语言实验报告3系级班年月日实验名称:Branches and Loops, Logical Arrays.姓名学号指导教师成绩 1 ObjectiveThe objective of this lab is to familiarize you with the MATLAB Branches and Loops,Logical Arrays.2 ExercisesDo not forget to add sufficient documentation and proper indentation to all programsyou write.(1) Write a program that calculates follow equation with for and while loop, and writea program without loop.63263022212+++==∑= i i K% for loopk1=0;for ii=1:64k1=k1+2^(ii-1);end% while loopk2=0;n=0;while n>=0&n<64k2=k2+2^n;n=n+1;end% without loopa=0:63;b=2.^a;K3=sum(b);(2) Write a program that accepts a vector of integers as input and counts the numberof integers that are multiples of 3 in that vector. You can assume that the inputcontains only integer values. An example run of your program can be as follows:Enter a vector of integers: [ 1 3 2 8 0 5 6 ]The number of multiples of 3 is 2(3) The root mean square is a way for calculating a mean fora set of numbers. The rmsaverage of a series of numbers is given as:∑==N i i xN rmsaverage 121Write a program that will accept an arbitrary number of input values and calculatethe rmsaverage of the numbers. The program should ask the user for the numberof values to be entered. Test your program with 4 and 10 set of numbers.% The root mean square is a way for calculating a mean for a set of numbers% Initializesum_x2=0;% Get the number of points to input.n=input('Enter number of points:');% Loop to read input valuesfor ii=1:n% Read in next valuex=input('Enter value:');% Calculate square sumssum_x2=sum_x2+x^2;end% Now calculate root mean squareroot_ms=sqrt(sum_x2/n);% Tell userfprintf('The number of data points is: %d\n',n);fprintf('The root mean square of this data set is: %f\n',root_ms);(4) 3.8 exercises:3.5(5) 4.7Exercises: 4.1 4.23 Quitting MATLABTyping quit on the command window will close the program. Do not forget to sendyour M-file to your TA.Do not forget to delete your files from the hard disk of the PC you used in the lab at the end of the lab session.四川师范大学MATLAB语言实验报告4系级班年月日实验名称:MATLAB/SIMULINK package姓名学号指导教师成绩1Objective●To learn how to use MATLAB/SIMULINK package●To learn how to estimate performance parameters from time-domain data2SIMULINK BasicBasic steps(1)Click on the MATLAB button to start MATLAB.(2)Once MATLAB has started up, type simulink (SMALL LETTERS!) at theMATLAB prompt (>>) followed by a carriage return (press the return key). A SIMULINK window should appear shortly, with the following icons: Sources, Sinks, Discrete, Linear, Connections, Extras.(3)Next, go to the File menu in SIMULINK window and choose New in order tobegin building the block diagram representation of the system of interest.(4)Open one or more of the block libraries and drag the chosen blocks into the active.(5)After the blocks are placed, draw lines to connect their input and output ports bymoving the mouse over a port and drag using the left button. To make a line witha right angle in it, release the button where you want thecorner, then click on theend of the line and drag to create next segment. To add a second line that runs off of an existing line click the right mouse on an existing line and drag it.(6)Save the system by selecting Save from the File menu.(7)Open the blocks by double-clicking and change some of their internal parameters.(8)Adjust some simulation parameters by selecting Parameters from the Simulationmenu. The most common parameter to change is Stop Time that defines the length of time the simulation will run.(9)Run the simulation by selecting Start from the Simulation menu. You can stop asimulation before completing by selecting Stop from the Simulation menu. (10)View the behavior of the system by attaching Scope blocks to the variables ofinterest, or by using To Workspace blocks to send data to the MATLAB workspace where you can plot the results using standard MATLAB commands.3Exercises(1)Your TA has shown you how to observe and print signals from the scope. Try thisout by printing out the input signal, which should be a -1V to 1V square wave with frequency 0.1 Hz. Note the peak-to-peak voltage difference of this signal.Note to write key blocks parameters.(2) Write a Simulink model to calculate the following differential equation,0)1(222=+--x dt dx x dt x d μInitialized 1)0(=x ,0)0(=dt dx 。
一、实验目的:1.学会运用Matlab解决实际问题2.进一步掌握Matlab的一些基本操作3.通过范例体会Matlab的初步建模过程4学会用做动画二.实验仪器、设备或软件:电脑、MATLAB软件三.实验内容:1.已知前两年的猪肉的产量和猪肉的价格分别为:39吨,28吨,12元/公斤,17元/公斤,根据前一年的猪肉价格影响后一年猪肉产量当年猪肉产量影响当年猪肉价格的线性关系,编写程序,利用动画原理画出前十年猪肉的产量——价格的动态图形。
(参数设置为,c1=39,c2=28,c3=36,r1=12,r2=17,k=16)。
2.在地面上建有一座圆柱形水塔,水塔内部的直径为d,并且在地面处开了一个高为H的小门.现在要对水塔内部进行维修施工,施工方案要求把一根长为l(l>d)的水管运到水塔内部.请问水塔的门高H多高时,才有可能成功地把水管搬进水塔内。
四.实验记录:1.蛛网模型:实验代码:clear%c1为产量1, c2为产量2, c3为产量3, r1为%肉价1, r2为肉价2, k为K年后产量与肉价%是否稳定c1=39;c2=28;c3=36;hold offr1=12;r2=17;k=16;a1=[c1 1;c2 1];%系数矩阵b1=[r1,r2]';%列向量a2=[r1 1;r2 1];b2=[c2,c3]';a=a1\b1;b=a2\b2;%x0(1)=c1;for n=1:30y0(n)=a(1)*x0(n)+a(2); %a(1)a(2)为矩阵元素的引用,下行类似x0(n+1)=b(1)*y0(n)+b(2);x(n)=x0(n);y(n)=x0(n+1);endplot(x,y0,'-g',y,y0,'-b')hold onm=moviein(100);for n=1:kfor j=1:30t1=x0(n)+(j-1)*(x0(n+1)-x0(n))/30;t2=x0(n)+j*(x0(n+1)-x0(n))/30;if t2<t1t=t1;t1=t2;t2=t;%这样做方便画图elseendt=t1:0.01:t2;plot(t,y0(n),'.r')%划横线t1=y0(n)+(j-1)*(y0(n+1)-y0(n))/30;t2=y0(n)+j*(y0(n+1)-y0(n))/30;if t2<t1t=t1;t1=t2;t2=t;elseendt=t1:0.01:t2;plot(x(n+1),t,'.r')%划竖线endm(:,n)=getframe;endmovie(m,20)实验结果:ans =Columns 1 through 639.0000 28.0000 36.0000 30.1818 34.4132 31.3358 Columns 7 through 1233.5739 31.9462 33.1300 32.2691 32.8952 32.4398 Columns 13 through 1832.7710 32.5302 32.7053 32.5779 32.6706 32.6032 Columns 19 through 2432.6522 32.6166 32.6425 32.6236 32.6374 32.6274 Columns 25 through 3032.6346 32.6294 32.6332 32.6304 32.6324 32.6310 Column 3132.6320实验图像:2.水塔模型:实验代码:Clearfunction x=lt523(l,d,h) k1=0;a=0l=7;d=3ymax=0;k2=0;b=pi/2;h=3;while (b-a)>10^(-2)k2=k2+1;m=0;a=0;if k1==0n=ceil(b/h)-1 elsen=ceil(b/h);endfor i=1:n+1;x(i)=a+(i-1)*(b-a)/n;y(i)=l*sin(x(i))-d*tan(x(i));endfor i=1:nif y(i)>ymaxymax=y(i);a=x(i-1);else y(i)<ymaxb=x(i);endendm=m+1;k1=k1+1;h=(b-a)/5;endabx=(a+b)/2t=0:0.01:1.35y1=l*sin(t)-d*tan(t);plot(t,y1,'-b')方法:2syms h xh=8*sin(x)-2*tan(x);d1=0;d2=pi/2;d0=(d1+d2)/2;d=0.03;a=subs(h,x,d1);b=subs(h,x,d2);c=subs(h,x,d0);for n=d1:d:d2if (((c-a)/(d0-d1))*((b-c)/(d2-d0)))<0 d1=d1+d; d2=d2-d; d0=(d1+d2)/2;a=subs(h,x,d1);b=subs(h,x,d2);c=subs(h,x,d0);endendd0hold onaxis([0,pi/2,-5,5])x=0:0.05:pi/2;plot(x,8*sin(x)-2*tan(x),'-b')实验运行结果:五、实验总结:通过做此实验,让我对MATLAB有更进一步的了解,学会怎样才能正确运用MATLAB求解实际问题,了解如何利用数学模型去解释和分析社会经济问题,特别是这个典型经济问题的求解。