matlab实验报告

合集下载

基于matlab的实验报告

基于matlab的实验报告

基于matlab的实验报告实验报告:基于MATLAB 的实验一、实验目的通过使用MATLAB 软件,掌握如何进行数据分析、图像处理、算法实现等一系列实验操作,提高实验者的实践能力和动手能力。

二、实验原理MATLAB 是一种在科学计算和技术开发领域广泛应用的计算机软件。

它能进行矩阵计算、绘制函数和数据图像、实现算法以及进行数据分析等。

通过掌握MATLAB 的使用,能够快速、高效地解决各种科学和工程问题。

三、实验内容1. 数据分析:使用MATLAB 的数据分析工具进行数据的导入、处理和分析。

2. 图像处理:利用MATLAB 的图像处理工具包对图像进行滤波、增强、分割等操作。

3. 算法实现:使用MATLAB 实现常用的算法,如排序、搜索、图像压缩等。

四、实验步骤1. 数据分析:(1)使用MATLAB 的读取数据函数将数据导入MATLAB 环境中。

(2)利用MATLAB 的数据处理函数进行数据清洗和预处理。

(3)使用MATLAB 的统计工具进行数据分析,如求平均值、标准差等。

(4)利用MATLAB 的绘图函数将分析结果可视化。

2. 图像处理:(1)使用MATLAB 的读取图像函数将图像导入MATLAB 环境中。

(2)利用MATLAB 的图像处理工具包进行滤波操作,如均值滤波、中值滤波等。

(3)使用MATLAB 的图像增强函数对图像进行锐化、变换等操作。

(4)利用MATLAB 的图像分割算法对图像进行分割。

3. 算法实现:(1)使用MATLAB 编写排序算法,如冒泡排序、快速排序等。

(2)使用MATLAB 编写搜索算法,如二分查找、线性搜索等。

(3)使用MATLAB 实现图像压缩算法,如离散余弦变换(DCT)。

五、实验结果实验中,我们使用MATLAB 完成了数据分析、图像处理和算法实现的一系列实验操作。

通过数据分析,我们成功导入了数据并对其进行了清洗和预处理,最后得到了数据的统计结果。

在图像处理方面,我们对图像进行了滤波、增强和分割等操作,最终得到了处理后的图像。

matlab实验报告

matlab实验报告

2) 在脚本文件中输入实验代码 3) 保存文件,存名字为 value.m 4) 在命令窗口中输入 value,得到实验结果 二、实验代码
三、实验结果
实验二
一、实验步骤:1)新建脚本 2)在编辑器中输入相应程序 3)在命令窗口执行文件,得到结果 1. 根据 6 = + + +…+ ,求π 的近似值。当 n 分别取 100、1000、10000 时,
1² 2² 3² ������ ² ������ ² 1 1 1 1
结果是多少?要求: 分别用循环结构和向量运算 (使用 sum 函数) 来实现。 1)循环结构 一、实验步骤 二、1)新建脚本 2)在编辑器中输入相应程序
3)保存文件,将文件命名为 PI.m 4)在命令窗口输入 PI 执行文件,得到结果 三、实验代码
四、实验结果
2. 根据 y=1+3 + 5 + ⋯ + 2������−1 ,求
(1) y2) 与(1)的 n 值对应的 y 值 一、实验步骤 1) 打开 matlab,新建脚本
1 2 4 3. 设 x= ,求 In(x+ 1 + ������²)的值,并分析结果矩阵中各元 2 −0.45 5
素的含义。
1 −2 67 3 54 2 4. 已知 A=34 −45 7 ,B=2 8 74 0 87 90 15 9 3
求下面的表达式的值。 (1) A*B 和 A.*B。 (2) A^3 和 A.^3.。 (3) A/B 和 A\B。 (4) [A,B]和[A([1,3],:);B^2]。
实验一
1. 设 x=-74°,y=-27°,求
sin ⁡ (������ 2 +������ 2 ) tan ⁡ |������ +������ |+������

Matlab课程论文(实验报告)

Matlab课程论文(实验报告)

1. 利用符号极限判定函数的连续性。

微积分是数学分析中的一个重要内容,是高等数学建立的基础和整个微分方程体系的基础内容。

Matlab 能够通过符号函数的计算实现微积分运算,如极限、微分、积分、级数等。

极限是当变量无限接近特定值时函数的值,例如,一元函数f(x)的导数f ’(x)的定义为下面的极限:f ’(x)=hx f h x f h )()(0lim -+→ Matlab 符号工具箱利用函数limit 计算符号的极限,其调用格式如下: ● l imit(expr, x , a):求x 趋近于a 的极限,但是当左、右极限不想同时,极限不存在。

● l imit(expr , a): 用 findsym(expr)作为独立变量。

● l imit(expr): 对x 求右趋于a=0的极限。

● l imit(expr, x , a , ‘left ’): 对x 求左趋于a 的极限。

● l imit(expr, x , a , ‘right ’): 对x 求左趋于a 的极限。

函数limit 要求第一个输入变量为符号函数,limit 不支持符号函数的句柄,但是对符号函数句柄f , 可以将f(x)作为输入变量。

例如:讨论函数f(x)= {0x x,0x ,2x 1)(cosx =≠= 的连续性。

求解过程:当x<0, x>0时,f(x)为初等函数,其连续性是显然的,只要考虑在x=0处的连续性。

根据需要,首先创建符号函数的M 文件,其源代码为:保存M 文件,名为ex0.m 。

调用limit 函数判定函数的连续性,代码为由结果可以看出,0lim →x f(x)=+→0lim x f(x)=-→0lim x f(x)=- 1/2 =0=f(0), 所以,在x=0时函数是不连续的。

2.在实际应用中,常常提出这样一种需求:把同一自变量的两个不用量纲、不同数量级的函数量的变化绘制在同一张图上。

例如希望在同一张图上表现出温度、湿度随时间的变化;人口数量、GDP 的变化曲线等。

综合实验报告Matlab

综合实验报告Matlab

综合实验报告Matlab综合实验报告:Matlab引言:Matlab是一种强大的数学计算软件,广泛应用于科学计算、数据分析和工程设计等领域。

本文将通过综合实验报告的形式,探讨Matlab在数据处理、图像处理和模拟仿真等方面的应用。

一、数据处理1.1 数据读取与处理在Matlab中,可以通过readtable函数读取各种格式的数据文件,如Excel表格、CSV文件等。

读取数据后,可以使用各种函数对数据进行处理,如排序、筛选、统计等。

此外,Matlab还提供了强大的绘图功能,可以直观地展示数据的分布和趋势。

1.2 数据拟合与回归分析Matlab提供了多种拟合和回归分析的函数,如polyfit、lsqcurvefit等。

通过这些函数,可以根据给定的数据点,拟合出最佳的曲线或曲面,从而预测未知数据的值。

这对于数据预测和趋势分析非常有用。

二、图像处理2.1 图像读取与显示Matlab支持多种图像格式的读取和显示,如JPEG、PNG、BMP等。

可以使用imread函数读取图像文件,并使用imshow函数显示图像。

同时,Matlab还提供了丰富的图像处理函数,如灰度化、二值化、平滑滤波等,可以对图像进行各种处理操作。

2.2 图像增强与特征提取通过Matlab的图像增强函数,如对比度调整、直方图均衡化等,可以改善图像的质量和清晰度。

此外,Matlab还提供了多种特征提取函数,如边缘检测、角点检测等,可以提取图像中的重要特征,用于目标识别和分析。

三、模拟仿真3.1 数学建模与仿真Matlab是一种优秀的数学建模工具,可以通过编写脚本文件,实现各种数学模型的建立和仿真。

例如,可以利用Matlab解决微分方程、优化问题等。

此外,Matlab还支持符号计算,可以进行符号运算和代数求解,方便进行复杂数学推导。

3.2 电路仿真与系统建模对于电子工程师来说,Matlab是一种不可或缺的工具。

Matlab提供了Simulink 工具箱,可以进行电路仿真和系统建模。

数值分析matlab实验报告

数值分析matlab实验报告

数值分析matlab实验报告《数值分析MATLAB实验报告》摘要:本实验报告基于MATLAB软件进行了数值分析实验,通过对不同数学问题的数值计算和分析,验证了数值分析方法的有效性和准确性。

实验结果表明,MATLAB在数值分析领域具有较高的应用价值和实用性。

一、引言数值分析是一门研究利用计算机进行数值计算和分析的学科,其应用范围涵盖了数学、物理、工程等多个领域。

MATLAB是一种常用的数值计算软件,具有强大的数值分析功能,能够进行高效、准确的数值计算和分析,因此在科学研究和工程实践中得到了广泛的应用。

二、实验目的本实验旨在通过MATLAB软件对数值分析方法进行实验验证,探究其在不同数学问题上的应用效果和准确性,为数值分析方法的实际应用提供参考和指导。

三、实验内容1. 利用MATLAB进行方程求解实验在该实验中,利用MATLAB对给定的方程进行求解,比较数值解和解析解的差异,验证数值解的准确性和可靠性。

2. 利用MATLAB进行数值积分实验通过MATLAB对给定函数进行数值积分,比较数值积分结果和解析积分结果,验证数值积分的精度和稳定性。

3. 利用MATLAB进行常微分方程数值解实验通过MATLAB对给定的常微分方程进行数值解,比较数值解和解析解的差异,验证数值解的准确性和可靠性。

四、实验结果与分析通过对以上实验内容的实际操作和分析,得出以下结论:1. 在方程求解实验中,MATLAB给出的数值解与解析解基本吻合,验证了MATLAB在方程求解方面的高准确性和可靠性。

2. 在数值积分实验中,MATLAB给出的数值积分结果与解析积分结果基本吻合,验证了MATLAB在数值积分方面的高精度和稳定性。

3. 在常微分方程数值解实验中,MATLAB给出的数值解与解析解基本吻合,验证了MATLAB在常微分方程数值解方面的高准确性和可靠性。

五、结论与展望本实验通过MATLAB软件对数值分析方法进行了实验验证,得出了数值分析方法在不同数学问题上的高准确性和可靠性。

MATLAB实验报告1(推荐文档)

MATLAB实验报告1(推荐文档)

学生实验报告一、实验目的 熟悉MATLAB 软件的用户环境;了解MATLAB 软件的一般命令;掌握MATLAB 向量、数组、矩阵操作与运算函数;掌握MATLAB 软件的基本绘图命令;掌握MATLAB 语言的几种循环、条件和开关选择结构,及其编程规范。

通过该实验的学习,使学生能灵活应用MATLAB 软件解决一些简单问题,能借助MATLAB 软件的绘图功能,对函数的特性进行探讨,广泛联想,大胆猜想,发现进而证实其中的规律。

二、实验仪器、设备或软件: 电脑,MATLAB 软件三、实验内容 1.MATLAB 软件的数组操作及运算练习;2.直接使用MATLAB 软件进行作图练习;3.用MATLAB 语言编写命令M 文件和函数M 文件。

四、实验步骤1.在D 盘建立一个自己的文件夹;2.开启软件平台——MATLAB ,将你建立的文件夹加入到MATLAB 的搜索路径中;3.利用帮助了解函数max, min, sum, mean, sort, length ,rand, size 和diag 的功能和用法;4.开启MATLAB 编辑窗口,键入你编写的M 文件(命令文件或函数文件);5.保存文件(注意将文件存入你自己的文件夹)并运行;6.若出现错误,修改、运行直到输出正确结果;7.写出实验报告,并浅谈学习心得体会。

五、实验要求与任务根据实验内容和步骤,完成以下具体实验,要求写出实验报告(实验目的→问题→算法与编程→计算结果或图形→心得体会)1. 已知矩阵⎥⎥⎥⎦⎤⎢⎢⎢⎣⎡=321212113A , ⎥⎥⎥⎦⎤⎢⎢⎢⎣⎡--=101012111B 要求:(1)屏幕输出A 与B ;(2)A 的转置A′;(3)求A+B 的值;(4)求A-B 的值;(5)求4A ;(6)求A×B ;(7)求A -1.2. 有一函数f (x ,y )=x 2+sin xy +2y ,写一程序,输入自变量的值,输出函数值。

3. 用plot ,fplot 分别绘制函数y =cos(tan(πx ))图形。

(完整word版)Matlab数学实验报告

Matlab 数学实验报告一、实验目的通过以下四组实验,熟悉MATLAB的编程技巧,学会运用MATLAB的一些主要功能、命令,通过建立数学模型解决理论或实际问题。

了解诸如分岔、混沌等概念、学会建立Malthu模型和Logistic 模型、懂得最小二乘法、线性规划等基本思想。

二、实验内容2.1实验题目一2.1.1实验问题Feigenbaum曾对超越函数y=λsin(πx)(λ为非负实数)进行了分岔与混沌的研究,试进行迭代格式x k+1=λsin(πx k),做出相应的Feigenbaum图2.1.2程序设计clear;clf;axis([0,4,0,4]);hold onfor r=0:0.3:3.9x=[0.1];for i=2:150x(i)=r*sin(3.14*x(i-1));endpause(0.5)for i=101:150plot(r,x(i),'k.');endtext(r-0.1,max(x(101:150))+0.05,['\it{r}=',num2str(r)]) end加密迭代后clear;clf;axis([0,4,0,4]);hold onfor r=0:0.005:3.9x=[0.1];for i=2:150x(i)=r*sin(3.14*x(i-1));endpause(0.1)for i=101:150plot(r,x(i),'k.');endend运行后得到Feigenbaum图2.2实验题目二2.2.1实验问题某农夫有一个半径10米的圆形牛栏,长满了草。

他要将一头牛拴在牛栏边界的桩栏上,但只让牛吃到一半草,问拴牛鼻子的绳子应为多长?2.2.2问题分析如图所示,E为圆ABD的圆心,AB为拴牛的绳子,圆ABD为草场,区域ABCD为牛能到达的区域。

问题要求区域ABCD等于圆ABC的一半,可以设BC等于x,只要求出∠a和∠b就能求出所求面积。

自动控制原理MATLAB仿真实验报告

实验一 典型环节的MATLAB 仿真 一、实验目的1.熟悉MATLAB 桌面和命令窗口,初步了解SIMULINK 功能模块的使用方法。

2.通过观察典型环节在单位阶跃信号作用下的动态特性,加深对各典型环节响应曲线的理解。

3.定性了解各参数变化对典型环节动态特性的影响。

二、实验内容① 比例环节1)(1=s G 和2)(1=s G ;Simulink 图形实现:示波器显示结果:② 惯性环节11)(1+=s s G 和15.01)(2+=s s GSimulink 图形实现:示波器显示结果:③ 积分环节s s G 1)(1Simulink 图形实现:示波器显示结果:④ 微分环节s s G )(1Simulink 图形实现:波器显示结果:⑤ 比例+微分环节(PD )2)(1+=s s G 和1)(2+=s s G1)、G1(s )=s+2Simulink 图形实现:示波器显示结果:2)、G2(s)=s+1 Simulink图形实现:示波器显示结果:⑥ 比例+积分环节(PI )s s G 11)(1+=和s s G 211)(2+=1)、G1(1)=1+1/sSimulink 图形实现:示波器显示结果:2)G2(s)=1+1/2s Simulink图形实现:示波器显示结果:三、心得体会通过这次实验我学到了很多,对课本内容加深了理解,熟悉MATLAB桌面和命令窗口,初步了解SIMULINK功能模块的使用方法,加深对各典型环节响应曲线的理解,这为对课程的学习打下了一定基础。

实验二线性系统时域响应分析一、实验目的1.熟练掌握step( )函数和impulse( )函数的使用方法,研究线性系统在单位阶跃、单位脉冲及单位斜坡函数作用下的响应。

2.通过响应曲线观测特征参量ζ和nω对二阶系统性能的影响。

3.熟练掌握系统的稳定性的判断方法。

二、实验内容1.观察函数step( )的调用格式,假设系统的传递函数模型为243237()4641s s G s s s s s ++=++++绘制出系统的阶跃响应曲线?2.对典型二阶系统222()2n n n G s s s ωζωω=++1)分别绘出2(/)n rad s ω=,ζ分别取0,0.25,0.5,1.0和2.0时的单位阶跃响应曲线,分析参数ζ对系统的影响,并计算ζ=0.25时的时域性能指标,,,,p r p s ss t t t e σ。

matlab 实验报告

matlab 实验报告Matlab 实验报告引言:Matlab(Matrix Laboratory)是一种强大的科学计算软件,它为科学家、工程师和研究人员提供了一个强大的计算环境。

本实验报告旨在介绍我对Matlab的实验结果和使用体验,以及对其优点和局限性的思考。

一、Matlab的基本功能和特点Matlab是一种高级编程语言和开发环境,它具有广泛的数学和工程计算功能。

通过Matlab,我可以进行矩阵运算、数值计算、数据可视化、算法开发等一系列操作。

Matlab的语法简洁易懂,可以快速实现复杂的计算任务。

此外,Matlab还提供了大量的工具箱,如信号处理、控制系统、图像处理等,使得各种领域的科学研究和工程应用变得更加便捷。

二、实验结果与应用案例在本次实验中,我选择了一个经典的数值计算问题——求解非线性方程。

通过Matlab的数值计算能力,我可以使用不同的迭代方法来求解方程的根。

在实验中,我使用了牛顿迭代法、二分法和割线法来求解方程。

通过对比这些方法的收敛速度和精度,我得出了不同方法的优缺点。

在实际应用中,Matlab可以广泛应用于信号处理、图像处理、数据分析等领域。

例如,在信号处理中,我可以使用Matlab的信号处理工具箱来进行滤波、频谱分析等操作。

在图像处理中,我可以利用Matlab的图像处理工具箱进行图像增强、边缘检测等操作。

这些应用案例充分展示了Matlab在科学计算和工程应用中的重要性和灵活性。

三、Matlab的优点1. 强大的计算功能:Matlab提供了丰富的数学和工程计算函数,可以高效地进行复杂的计算任务。

2. 简洁的语法:Matlab的语法简洁易懂,使得编程变得更加高效和便捷。

3. 丰富的工具箱:Matlab提供了大量的工具箱,覆盖了各种领域的科学计算和工程应用需求。

4. 可视化能力强:Matlab提供了丰富的绘图函数,可以直观地展示数据和计算结果。

四、Matlab的局限性1. 高昂的价格:Matlab是一款商业软件,其价格较高,对于个人用户而言可能不太容易承受。

MATLAB实验报告(8个实验)

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-window on 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 usage 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 the points (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 behind in 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 array subscripts. 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 any nonzero value as true. Relational operators ( ==, =,>,>=,<,<=) are operators with two operands that produce either a true (1) or a false (0) result, depending on the values of the 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 same size. Be careful not to confuse the equivalence relational operator ( == ) with the assignment operator ( = ). Logic operators ( &, |, xor, ~ ) are operators with one ortwo operands that yield a logical result such as 0 or 1. There are three binary logic operators: AND (& ), OR ( |), and exclusive OR ( xor ); and one unary operator: NOT ( ~ ). In the hierarchy of operations, logic operators are evaluated after allarithmetic and relational operators have been evaluated. The operator is evaluated before 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 following result.=110001110011110111115arrarr5=arr4>0;(3) Write an expression using arr4 and a relational operator to produce the following result.=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 and column 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 send your 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 at the 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 programs you 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 for a 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 the corner, 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. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

选题说明:根据学号最后两位数字模6的余数确定题号,余数为1的做第1题,余数为2的做第2题,。

,余数为5的做第5题,余数为0的做第6题。

本次实验报告要求独立完成,基本雷同者全部按零分处理,必须提供电子版和纸质打印版, 12月18日之前务必交到学习委员处,逾期不计成绩。

1、 多元线性回归问题
根据下述某猪场25头育肥猪4个身体特征的数据资料,试进行瘦肉量y 对眼肌面积(x )、腿肉量(x )、腰肉量(x )的多元线性回归分析。

1)画出散点图y 与x1,y 与x2,y 与x3,并观察y 与x1,x2, x3的关系; 2)求y 关于x1,x2, x3的线性回归方程:0112233y x x x ββββ=+++,求出0123,,,ββββ的值;
3)对上述回归模型和回归系数进行检验;
4)再分别求y 关于单个变量x1,x2, x3的线性回归方程:10111y x ββ=+,
20222y x ββ=+,30333y x ββ=+,求出上述回归系数ij β的值;分别求y 关于x1,x2, x3
中任意两个变量的线性回归方程,并求出回归系数的值;并说明这六个回归方程对原来问题求解的优劣。

5)编程实现上述求解过程。

2、 非线性回归问题-------多项式回归
给动物口服某种药物A 1000mg ,每间隔1小时测定血药浓度(g/ml ),得到表9-5的数据(血药浓度为5头供试动物的平均值)。

血药浓度与服药时间测定结果表:
服药时间x 1(小时) 1 2 3 4 5 6 7 8 9 血药浓度y (g/ml )
21.89
47.13
61.86
70.78
72.81
66.36
50.34
25.31
3.17
要求:1)画出散点图y 与x ,并观察y 与x 的关系;
2)求y 关于x1的一元线性回归方程:011y x ββ=+,求出01,ββ的值; 3)对上述回归模型和回归系数进行检验;
4)再求y 关于x1的一元多项式线性回归方程。

(如: 201121y a a x a x =++等),求出回归系数012,,a a a 的值,并与线性回归方程比较对原来问题求解的优劣。

5)编程实现上述求解过程。

3、微分方程问题1
美国原子能委员会以往处理浓缩的放射性废料的方法,一直是把它们装入密封的圆桶里,然后扔到水深为90多米的海底。

生态学家和科学家们表示担心,怕圆桶下沉到海底时与海底碰撞而发生破裂,从而造成核污染。

原子能委员会分辨说这是不可能的。

为此工程师们进行了碰撞实验,发现当圆桶下沉速度超过12.2m/s 与海底相撞时,圆桶就可能发生碰裂。

这样为避免圆桶碰裂,需要计算一下圆桶沉到海底时速度是多少?这时已知圆桶重量为239.46kg ,体积为0.2058m 3, 海水密度为1035.71 kg / m 3。

如果圆桶速度小于12.2m/s ,就说明这种方法是安全可靠的,否则就要禁止用这种方法来处理放射性废料。

假设水的阻力与速度大小成正比例,其正比例常数k=0.6。

1) 建立解决上述问题的微分方程数学模型。

2) 用解析和数值两种方法编程求解上述微分方程,并回答是否要禁止用这种方法来处理放射性废料。

4、微分方程问题2
在一个封闭的大草原生长着狐狸和野兔,设t 时刻它们的数量分别为y(t)和x(t),已知满足下列微分方程组 :
0.0010.9
40.02
dy xy y dt dx
x xy dt
=-=-
1)求上述微分方程的轨线方程: F(x,y)=0
2)在什么情况下狐狸和野兔数量出现平衡状态
3)建立另一个微分方程来分析人们对野兔进行捕猎会产生什么后果?对狐狸进行捕
猎又会产生什么后果? 4)对上述问题理论分析并编程模拟。

5、微分方程问题3
搜集历年中国人口数据,编程检验其是否服从马尔萨斯人口增长指数模型,并至少采用两种不同模型,并编程计算对2015年我国人口进行预测。

6、微积分问题
至少选择四种不同方法计算圆周率π的近似值,比较精度、迭代次数、运行时间等,并编程实现。

相关文档
最新文档