Matlab课程论文(实验报告)
MATLAB实验报告

MATLAB实验报告一、实验目的本次 MATLAB 实验旨在深入了解和掌握 MATLAB 软件的基本操作和应用,通过实际编程和数据处理,提高解决问题的能力,培养编程思维和逻辑分析能力。
二、实验环境本次实验使用的是 MATLAB R2020a 版本,运行在 Windows 10 操作系统上。
计算机配置为英特尔酷睿 i5 处理器,8GB 内存。
三、实验内容(一)矩阵运算1、矩阵的创建使用直接输入、函数生成和从外部文件导入等方式创建矩阵。
例如,通过`1 2 3; 4 5 6; 7 8 9` 直接输入创建一个 3 行 3 列的矩阵;使用`ones(3,3)`函数创建一个 3 行 3 列元素全为 1 的矩阵。
2、矩阵的基本运算包括矩阵的加减乘除、求逆、转置等。
例如,对于两个相同维度的矩阵`A` 和`B` ,可以进行加法运算`C = A + B` 。
3、矩阵的特征值和特征向量计算通过`eig` 函数计算矩阵的特征值和特征向量,加深对线性代数知识的理解和应用。
(二)函数编写1、自定义函数使用`function` 关键字定义自己的函数,例如编写一个计算两个数之和的函数`function s = add(a,b) s = a + b; end` 。
2、函数的调用在主程序中调用自定义函数,并传递参数进行计算。
3、函数的参数传递了解值传递和引用传递的区别,以及如何根据实际需求选择合适的参数传递方式。
(三)绘图功能1、二维图形绘制使用`plot` 函数绘制简单的折线图、曲线等,如`x = 0:01:2pi; y = sin(x); plot(x,y)`绘制正弦曲线。
2、图形的修饰通过设置坐标轴范围、标题、标签、线条颜色和样式等属性,使图形更加清晰和美观。
3、三维图形绘制尝试使用`mesh` 、`surf` 等函数绘制三维图形,如绘制一个球面`x,y,z = sphere(50); surf(x,y,z)`。
(四)数据处理与分析1、数据的读取和写入使用`load` 和`save` 函数从外部文件读取数据和将数据保存到文件中。
4)MATLAB实验报告

4)MATLAB实验报告MATLAB实验报告一、引言MATLAB是一种强大的数学软件,广泛应用于科学研究、工程设计和数据分析等领域。
本实验报告旨在介绍使用MATLAB进行数据处理和可视化的基本方法,并通过实例展示其应用。
二、数据处理1. 数据导入与读取在MATLAB中,可以使用load函数或importdata函数导入外部数据文件。
load函数适用于导入MATLAB格式的数据文件,而importdata函数可以导入多种格式的数据文件,如文本文件、Excel文件等。
2. 数据清洗与转换数据清洗是指对原始数据进行去除异常值、缺失值填充等处理,以保证数据的准确性和完整性。
MATLAB提供了丰富的函数和工具箱,如统计工具箱、优化工具箱等,可以方便地进行数据清洗和转换操作。
3. 数据分析与建模MATLAB具有强大的数学和统计分析功能,可以进行数据的描述性统计、回归分析、时间序列分析等。
通过使用相关函数和工具箱,可以对数据进行深入分析,并建立相应的数学模型。
三、数据可视化1. 统计图表MATLAB提供了丰富的绘图函数和工具箱,可以绘制各种统计图表,如直方图、散点图、箱线图等。
这些图表可以直观地展示数据的分布、关系和趋势,有助于更好地理解和解释数据。
2. 三维可视化除了二维图表外,MATLAB还支持三维数据的可视化。
通过使用plot3函数、mesh函数等,可以将三维数据以曲线、曲面等形式展示出来,进一步提供对数据的深入理解。
3. 动态可视化MATLAB还支持动态可视化,即通过动画或交互式图形来展示数据的变化过程。
通过使用animate函数、interactiveplot函数等,可以将数据的变化以动态的方式展示出来,增加数据分析和呈现的趣味性。
四、实例应用以某电商平台销售数据为例,展示如何使用MATLAB进行数据处理和可视化。
首先,导入销售数据文件,清洗数据,去除异常值和缺失值。
然后,通过统计分析,计算销售额、销量、平均价格等指标,并绘制相应的统计图表。
(最新版)MATLAB实验报告

(最新版)MATLAB实验报告实验一典型环节的MATLAB仿真一、实验目的1.熟悉MATLAB桌面和命令窗口,初步了解SIMULINK功能模块的使用方法。
2.通过观察典型环节在单位阶跃信号作用下的动态特性,加深对各典型环节响应曲线的理解。
3.定性了解各参数变化对典型环节动态特性的影响。
二、SIMULINK的使用MATLAB中SIMULINK是一个用来对动态系统进行建模、仿真和分析的软件包。
利用SIMULINK功能模块可以快速的建立控制系统的模型,进行仿真和调试。
1.运行MATLAB软件,在命令窗口栏“>>”提示符下键入simulink命令,按Enter 键或在工具栏单击按钮,即可进入如图1-1所示的SIMULINK仿真环境下。
2.选择File菜单下New下的Model命令,新建一个simulink 仿真环境常规模板。
3.在simulink仿真环境下,创建所需要的系统。
以图1-2所示的系统为例,说明基本设计步骤如下:1)进入线性系统模块库,构建传递函数。
点击simulink下的“Continuous”,再将右边窗口中“Transfer Fen”的图标用左键拖至新建的“untitled”窗口。
2)改变模块参数。
在simulink仿真环境“untitled”窗口中双击该图标,即可改变传递函数。
其中方括号内的数字分别为传递函数的分子、分母各次幂由高到低的系数,数字之间用空格隔开;设置完成后,选择OK,即完成该模块的设置。
3)建立其它传递函数模块。
按照上述方法,在不同的simulink 的模块库中,建立系统所需的传递函数模块。
例:比例环节用“Math”右边窗口“Gain”的图标。
4)选取阶跃信号输入函数。
用鼠标点击simulink下的“Source”,将右边窗口中“Step”图标用左键拖至新建的“untitled”窗口,形成一个阶跃函数输入模块。
5)选择输出方式。
用鼠标点击simulink下的“Sinks”,就进入输出方式模块库,通常选用“Scope”的示波器图标,将其用左键拖至新建的“untitled”窗口。
Matlab实验报告

实验一:Matlab操作环境熟悉一、实验目的1.初步了解Matlab操作环境。
2.学习使用图形函数计算器命令funtool及其环境。
二、实验内容熟悉Matlab操作环境,认识命令窗口、内存工作区窗口、历史命令窗口;学会使用format命令调整命令窗口的数据显示格式;学会使用变量和矩阵的输入,并进行简单的计算;学会使用who和whos命令查看内存变量信息;学会使用图形函数计算器funtool,并进行下列计算:1.单函数运算操作。
求下列函数的符号导数(1)y=sin(x); (2) y=(1+x)^3*(2-x);求下列函数的符号积分(1)y=cos(x);(2)y=1/(1+x^2);(3)y=1/sqrt(1-x^2);(4)y=(x1)/(x+1)/(x+2)求反函数(1)y=(x-1)/(2*x+3); (2) y=exp(x); (3) y=log(x+sqrt(1+x^2));代数式的化简(1)(x+1)*(x-1)*(x-2)/(x-3)/(x-4);(2)sin(x)^2+cos(x)^2;(3)x+sin(x)+2*x-3*cos(x)+4*x*sin(x);2.函数与参数的运算操作。
从y=x^2通过参数的选择去观察下列函数的图形变化(1)y1=(x+1)^2(2) y2=(x+2)^2(3) y3=2*x^2 (4) y4=x^2+2 (5) y5=x^4 (6)y6=x^2/23.两个函数之间的操作求和(1)sin(x)+cos(x) (2) 1+x+x^2+x^3+x^4+x^5乘积(1)exp(-x)*sin(x) (2) sin(x)*x商(1)sin(x)/cos(x); (2) x/(1+x^2); (3) 1/(x-1)/(x-2);求复合函数(1)y=exp(u) u=sin(x) (2) y=sqrt(u) u=1+exp(x^2)(3) y=sin(u) u=asin(x) (4) y=sinh(u) u=-x实验二:MATLAB基本操作与用法一、实验目的1.掌握用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实验报告

实验结果及分析实验1:程序如下x=1:10y=2*x;plot(x,y)仿真结果:实验结果分析:仿真结果是条很规则的直线,X轴和Y轴一一对应,清楚明了,而序又特别简单。
所以用Maltab 软件很方便地画出规则的直线,方便研究。
实验结果及分析1、A=2、A=1A=实验结果及分析实验三 Matlab在信号与系统中的应用实验名称实验1、掌握信号与系统课程中基本知识的Matlab编程、仿真方法目的实验原理实验1程序:b=[1];a=[1 1];p=;t=0:p:5;x=exp(-3*t);subplot(1,2,1);impulse(b,a,0:p:5);title('冲激响应');subplot(1,2,2);step(b,a,0:p:5);title('阶跃响应');实验内容<设计性实验>1、用MATLAB在时域中编程求解y′(t)+y(t)=f(t), f(t)= exp(-3t)ε(t)的冲激响应、阶跃响应。
在simulink仿真环境下,设计系统框图,分析系统的冲激响应、阶跃响应。
<设计性实验>(选做)2、用MATLAB在时域中编程求解y′(t)+y(t)=f(t), f(t)=(1+exp(-3t))ε(t)的冲激响应、阶跃响应,要求用conv编程实现系统响应。
在simulink仿真环境下,设计系统框图,分析系统的冲激响应、阶跃响应。
实验结果及分析实验1仿真结果:simulink仿真环境下冲激响应阶跃响应实验名称实验四 Matlab在数字信号处理中的应用实验结果及分析实验1仿真结果:6khz12kHZ。
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 first 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) Define 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 files 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 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 one unary 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 for a set of numbers. The rmsaverage of a series of numbers is given as:∑==N i i x N 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 。
matlab实验报告1

matlab实验报告1MATLAB实验报告1摘要:本实验使用MATLAB软件进行了一系列的实验,主要包括数据处理、图像处理和信号处理。
通过实验,我们掌握了MATLAB软件在科学计算和工程领域的应用,深入了解了MATLAB在数据处理、图像处理和信号处理方面的强大功能。
一、数据处理实验在数据处理实验中,我们使用MATLAB对一组实验数据进行了分析和处理。
首先,我们导入了实验数据并进行了数据清洗和预处理,然后利用MATLAB的统计分析工具对数据进行了描述性统计分析,包括均值、方差、标准差等指标的计算。
接着,我们利用MATLAB的绘图工具绘制了数据的直方图和散点图,直观地展现了数据的分布规律和相关性。
二、图像处理实验在图像处理实验中,我们使用MATLAB对一幅图像进行了处理和分析。
首先,我们读取了图像并进行了灰度化处理,然后利用MATLAB的图像滤波工具对图像进行了平滑和锐化处理,最后利用MATLAB的图像分割工具对图像进行了分割和特征提取。
通过实验,我们深入了解了MATLAB在图像处理领域的应用,掌握了图像处理的基本原理和方法。
三、信号处理实验在信号处理实验中,我们使用MATLAB对一组信号进行了处理和分析。
首先,我们生成了一组模拟信号并进行了频域分析,利用MATLAB的信号滤波工具对信号进行了滤波处理,然后利用MATLAB的频谱分析工具对信号的频谱特性进行了分析。
通过实验,我们深入了解了MATLAB在信号处理领域的应用,掌握了信号处理的基本原理和方法。
综上所述,本实验通过对MATLAB软件的应用实验,使我们对MATLAB在数据处理、图像处理和信号处理方面的功能有了更深入的了解,为我们今后在科学计算和工程领域的应用奠定了良好的基础。
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-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 。
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实验报告

matlab实验报告Matlab实验报告实验题目:利用Matlab进行数据处理与分析实验目的:通过使用Matlab进行数据处理与分析的实践,掌握Matlab的基本操作和数据处理的方法。
实验内容:1. 数据读取:从文件中读取原始数据,并进行初步的观察和分析。
2. 数据清洗:对原始数据进行清洗,包括去除空值、异常值等。
3. 数据可视化:利用Matlab的绘图函数,将数据可视化呈现,以方便对数据进行进一步的分析和理解。
4. 数据分析:对清洗后的数据进行统计分析,包括求平均值、方差、相关系数等。
5. 模型建立:根据数据分析的结果,建立合适的数学模型,并使用Matlab进行参数估计和模型验证。
6. 结果验证:利用实验数据和模型进行实验结果的对比,验证模型的准确性和可靠性。
实验步骤:1. 准备实验数据:从实验样本中获得原始数据,并将其存储为文本文件。
2. 使用Matlab导入数据:使用Matlab的数据导入函数,将文本文件中的数据导入到Matlab的工作空间中。
3. 数据分析与处理:使用Matlab的数据处理函数,对导入的数据进行清洗和处理,去除异常值和空值,并进行初步的数据观察和分析。
4. 数据可视化:利用Matlab的绘图函数,绘制数据的直方图、散点图、折线图等,以展示数据的分布和趋势。
5. 数据统计分析:使用Matlab的统计分析函数,对处理后的数据进行统计分析,包括计算平均值、方差、相关系数等。
6. 模型建立与验证:根据数据分析的结果,建立合适的数学模型,并使用Matlab进行参数估计和模型验证。
7. 结果对比和讨论:将实验结果与模型预测结果进行对比,并进行结果的讨论和分析。
8. 实验结论:总结实验结果并给出结论。
实验结果:根据实验数据的分析和处理,得出如下结论:1. 数据呈现正态分布,符合正态性假设。
2. 数据之间存在显著的正相关关系,相关系数为0.8,结果具有统计学意义。
3. 建立的数学模型与实验数据拟合良好,模型预测结果与实验结果吻合度高。
MATLAB实验报告

MATLAB实验报告MATLAB 实验报告姓名:专业:学号:实验⼀ MATLAB环境的熟悉与基本运算⼀、实验⽬的:1.熟悉MATLAB开发环境2.掌握矩阵、变量、表达式的各种基本运算⼆、实验基本知识:1.熟悉MATLAB环境:MATLAB桌⾯和命令窗⼝、命令历史窗⼝、帮助信息浏览器、⼯作空间浏览器⽂件和搜索路径浏览器。
2.掌握MATLAB常⽤命令3.MATLAB变量与运算符变量命名规则如下:(1)变量名可以由英语字母、数字和下划线组成(2)变量名应以英⽂字母开头(3)长度不⼤于31个(4)区分⼤⼩写MATLAB中设置了⼀些特殊的变量与常量,列于下表。
MATLAB运算符,通过下⾯⼏个表来说明MATLAB的各种常⽤运算符表2 MATLAB算术运算符表3 MATLAB关系运算符表4 MATLAB逻辑运算符表5 MATLAB特殊运算4.MATLAB的⼀维、⼆维数组的寻访表6 ⼦数组访问与赋值常⽤的相关指令格式5.MATLAB的基本运算表7 两种运算指令形式和实质内涵的异同表6.MATLAB的常⽤函数表8 标准数组⽣成函数表9 数组操作函数三、实验内容1、学习安装MATLAB软件。
2、学习使⽤help命令,例如在命令窗⼝输⼊help eye,然后根据帮助说明,学习使⽤指令eye(其它不会⽤的指令,依照此⽅法类推)3、学习使⽤clc、clear,观察command window、command history和workspace 等窗⼝的变化结果。
4、初步程序的编写练习,新建M-file,保存(⾃⼰设定⽂件名,例如exerc1、exerc2、exerc3……),学习使⽤MATLAB的基本运算符、数组寻访指令、标准数组⽣成函数和数组操作函数。
注意:每⼀次M-file的修改后,都要存盘。
四、实验结果练习A:(1)help rand,然后随机⽣成⼀个2×6的数组,观察command window、command history和workspace等窗⼝的变化结果。
matlab实验报告

matlab实验报告实验报告:Matlab实验分析1. 实验目的本实验旨在通过Matlab软件完成一系列数值计算和数据分析的任务,包括绘制曲线、解方程、矩阵运算等,以加深对Matlab软件的理解和掌握。
2. 实验内容2.1 绘制函数曲线首先,我们通过在Matlab中输入函数的表达式来绘制函数曲线。
例如,我们可以输入y = sin(x)来绘制正弦函数的曲线。
另外,我们还可以设置曲线的颜色、线型和坐标轴范围等。
2.2 解方程接下来,我们使用Matlab来解方程。
对于一元方程,我们可以使用solve函数来求出方程的解。
例如,我们输入syms x; solve(x^2 - 2*x - 8)来解方程x^2 - 2x - 8 = 0。
而对于多元方程组,我们可以使用solve函数的向量输入形式来求解。
例如,我们输入syms x y; solve(x^2 + y^2 - 1, x - y - 1)来求解方程组x^2 + y^2 - 1 = 0和x - y - 1 = 0的解。
2.3 矩阵运算Matlab也可以进行矩阵运算。
我们可以使用矩阵相乘、相加和取逆等运算。
例如,我们可以输入A = [1 2; 3 4]和B = [5 6;7 8]来定义两个矩阵,然后使用A * B来计算它们的乘积。
3. 实验结果与分析在本实验中,我们成功完成了绘制函数曲线、解方程和矩阵运算等任务。
通过Matlab软件,我们可以快速、准确地进行数值计算和数据分析。
使用Matlab的高级函数和工具箱,我们可以更方便地处理复杂的数值计算和数据分析问题。
4. 实验总结通过本次实验,我们进一步加深了对Matlab软件的理解和掌握。
Matlab提供了丰富的函数库和工具箱,适用于各种不同的数值计算和数据分析任务。
在日常科研和工程实践中,Matlab是一个非常强大和方便的工具,可以帮助我们更高效地完成任务。
MATLAB实验报告模板

《MATLAB语言》课程论文MATLAB在力学分析中的应用姓名:学号:专业:班级:指导老师:学院:完成日期:MATLAB 在力学分析中的应用( 姓名 12008243764 2008级2班)[摘要]大学物理力学中涉及许多复杂的数值计算问题,例如非线性问题,对其手工求解较为复杂,而MATLAB 语言正是处理非线性问题的很好工具,既能进行数值求解,又能绘制有关曲线,非常方便实用。
另外,利用其可减少工作量,节约时间,加深理解,同样可以培养应用能力 。
[关键词]力学 重力场 阻尼振动 MATLAB 语言 图形绘制一、问题的提出MATLAB 语言是当今国际上科学界 (尤其是自动控制领域) 最具影响力、也是最有活力的软件。
它提供了强大的科学运算、灵活的程序设计流程、高质量的图形可视化与界面设计、便捷的与其他程序和语言接口的功能。
MATLAB 语言在各国高校与研究单位起着重大的作用.它是一种集数值计算、符号运算、可视化建模、仿真和图形处理等多种功能……二、重力场中小球落点问题在物理课程的学习中我们可以明确的得到解决落体运动的方程:22d y m mg dt=- (1) 例:一弹性球,初始高度 h=10m,向上初速度 v0=15m/s, 与地相碰的速度衰减系数 k=0.8,计算任意时刻球的速度和位置。
分析:用传统计算方法解决时我们需要列出传统方程,我们明显可以感觉到,这样的计算不仅繁琐费时,而且没有图示很难给以直观的感受,现在我们用MATLAB 语言来对此例题做以下解析:MATLAB 程序如下:clear all %有衰减弹性小球运动程序v0=15; h=10; %初速度、高度g=-9.8; k=0.8; % 重力加速度 衰减系数运行结果如图1所示。
图1 小球落地速度及位置曲线通过以上程序对小球落地速度、位置以及运动过程的坐标描述,我们就会发现其在此类问题中直观的表述,那么现在我们来解决另外一个问题。
三、解决阻尼振动与受迫震动图像问题1、阻尼振动方程红线—简谐振动,蓝线22βω<的阻尼振动,绿线220βω→的阻尼振动,阻尼振动周期比自由振动要长,当2200.99βω= 时,振幅按指数迅速缩减。
matlab实验报告

matlab实验报告《matlab 实验报告》一、实验目的通过本次实验,熟悉 MATLAB 软件的基本操作和功能,掌握使用MATLAB 进行数学计算、数据处理、图形绘制等方面的方法和技巧,提高运用 MATLAB 解决实际问题的能力。
二、实验环境1、计算机:_____2、操作系统:_____3、 MATLAB 版本:_____三、实验内容及步骤(一)矩阵运算1、创建矩阵在 MATLAB 中,可以通过直接输入元素的方式创建矩阵,例如:`A = 1 2 3; 4 5 6; 7 8 9`,创建了一个 3 行 3 列的矩阵 A。
还可以使用函数来创建特定类型的矩阵,如全零矩阵`zeros(m,n)`、全 1 矩阵`ones(m,n)`、单位矩阵`eye(n)`等。
2、矩阵的基本运算加法和减法:两个矩阵相加或相减,要求它们的维度相同,对应元素进行运算。
乘法:矩阵乘法需要满足前一个矩阵的列数等于后一个矩阵的行数。
转置:使用`A'`来获取矩阵 A 的转置。
(二)函数的使用1、自定义函数可以在 MATLAB 中自定义函数,例如定义一个计算两个数之和的函数:```matlabfunction s = add_numbers(a,b)s = a + b;end```2、调用函数在命令窗口中输入`add_numbers(3,5)`即可得到结果 8。
(三)数据的读取和写入1、读取数据使用`load`函数可以读取数据文件,例如`load('datatxt')`。
2、写入数据使用`save`函数可以将数据保存到文件中,例如`save('resulttxt',A)`,将矩阵 A 保存到`resulttxt`文件中。
(四)图形绘制1、二维图形绘制折线图:使用`plot(x,y)`函数,其中 x 和 y 分别是横坐标和纵坐标的数据。
绘制柱状图:使用`bar(x,y)`函数。
2、三维图形绘制三维曲线:使用`plot3(x,y,z)`函数。
matlab实验报告

matlab实验报告Matlab实验报告引言:Matlab(Matrix Laboratory)是一种高级的计算机编程语言和环境,主要用于数值计算、数据分析和可视化。
它的功能强大,被广泛应用于科学研究、工程设计和教学实验等领域。
本实验报告将介绍我在使用Matlab进行实验过程中的一些经验和收获。
一、Matlab的基本语法和数据类型Matlab的语法与其他编程语言相比较简单,但仍然需要掌握一些基本的语法规则。
例如,Matlab中的变量命名不区分大小写,但建议使用小写字母来命名变量。
Matlab支持多种数据类型,包括数值型、字符型、逻辑型等。
在实验中,我常常使用数值型数据进行计算和分析。
二、Matlab中的矩阵运算矩阵运算是Matlab的重要特性之一,它使得处理大量数据变得更加高效和简便。
我在实验中经常使用矩阵运算来进行数据的处理和分析。
例如,我可以使用矩阵乘法来计算两个矩阵的乘积,或者使用矩阵的转置来进行数据的重排和变换。
Matlab还提供了丰富的矩阵运算函数,如求逆矩阵、特征值分解等,这些函数大大简化了复杂计算的过程。
三、Matlab的数据可视化Matlab提供了强大的数据可视化功能,可以帮助我们更直观地理解和展示数据。
在实验中,我常常使用Matlab绘制曲线图、散点图和柱状图等,以便更清晰地观察数据的分布和趋势。
Matlab的绘图函数丰富多样,可以根据不同的需求选择合适的图形类型和样式。
此外,Matlab还支持图像处理和三维可视化等高级功能,这些功能在科学研究和工程设计中有着广泛的应用。
四、Matlab的编程和调试Matlab不仅是一种计算工具,还是一种编程语言。
通过编写脚本和函数,我们可以实现更复杂的计算和操作。
在实验中,我常常使用Matlab编写自定义函数来实现特定的功能。
编程过程中,我注意到Matlab的调试功能非常强大,可以帮助我们找出代码中的错误和问题。
Matlab提供了断点调试、变量监视和错误提示等功能,这些功能对于提高代码的可靠性和效率非常有帮助。
matlab实验报告

matlab实验报告实验1 熟悉matlab的开发环境及矩阵操作一、实验的教学目标通过本次实验使学生熟悉MATLAB7.0的开发环境,熟悉MATLAB工作界面的多个常用窗口包括命令窗口、历史命令窗口、当前工作目录窗口、工作空间浏览器窗口等。
掌握建立表达式书写规则及常用函数的使用,建立矩阵的几种方法。
二、实验环境计算机、MATLAB7.0集成环境三、实验内容1、熟悉命令窗口的使用,工作空间窗口的使用,工作目录、搜索路径的设置。
命令历史记录窗口的使用,帮助系统的使用。
2、在当前命令窗口中输入以下命令:x=0:2:10 y=sqrt(x),并理解其含义。
3、求下列表达式的值(1)w=2?(1?0.34245?10?6)b?c?e2,其中a=3.5,b=5,c=-9.8 tan(b?c)?a2?a?(2)x=四、实验总结1、熟悉了命令窗口的使用,工作空间窗口的使用。
2、了解了工作目录、搜索路径的设置方法。
实验2 MATLAB基本运算一、实验的教学目标通过本次实验使学生掌握向量和矩阵的创建方法;掌握矩阵和数组的算术运算、逻辑运算和关系运算;掌握字符数组的创建和运算;了解创建元胞数组和结构体的方法。
二、实验环境计算机、MATLAB7.0集成环境三、实验内容1、要求在闭区间[0,2?]上产生具有10个等距采样点的一维数组。
试用两种不同的指令实现。
(提示:冒号生成法,定点生成法)2、由指令rng('default'),A=rand(3,5)生成二维数组A,试求该数组中所有大于0.5的元素的位置,分别求出它们的“全下标”和“单下标”。
(提示:find和sub2ind)3、创建3阶魔方矩阵a和3阶对角阵b,c=a(1:3,1:3)(1)计算矩阵a,b和c的行列式、逆矩阵并进行最大值的统计。
(2)比较矩阵和数组的算术运算:b和c的*、/、^和.*、./、.^。
2451??1321? ?567?9??2623。
MATLAB实验报告

MATLAB实验报告题目一:图像的基本处理与分析实验目的:1.学习图像读取与显示的基本操作;2.掌握图像的灰度化、二值化、直方图均衡化等基本处理方法;3.学会使用MATLAB分析图像的特征。
实验步骤:1.读取图像并显示;2.将彩色图像灰度化并显示;3.对灰度图像进行二值化处理,并进行显示;4.对二值化图像进行直方图均衡化,并进行显示;5.分析图像的特征,如平均亮度、最大亮度、最小亮度等。
实验结果:1.读取图像并显示:```matlabimg = imread('image.jpg');imshow(img);```2.图像灰度化并显示:```matlabgray_img = rgb2gray(img);imshow(gray_img);```3.图像二值化处理与显示:```matlabthreshold = graythresh(gray_img);binary_img = imbinarize(gray_img, threshold);imshow(binary_img);```4.图像直方图均衡化与显示:```matlabeq_img = histeq(gray_img);imshow(eq_img);```5.图像特征分析:```matlabmean_value = mean(gray_img(:));max_value = max(gray_img(:));min_value = min(gray_img(:));```实验结论:通过本次实验,我学会了图像的基本处理与分析方法。
图像的灰度化、二值化、直方图均衡化是图像处理的基本操作,可以根据具体需求选择使用。
通过分析图像的特征,可以得到图像的平均亮度、最大亮度、最小亮度等信息,这对于图像的后续处理和分析非常重要。
Matlab实践实验报告

实验一Matlab实践综合实验一、实验目的和要求1.掌握Matlab使用的最基本命令和技巧。
2.掌握用Matlab表示信号的方法及信号波形的绘制方法。
3.了解在给定系统函数的条件下,如何调用Matlab函数绘制系统的频率响应特性曲线。
4.掌握在Matlab中信号频谱的求解和频谱图的绘制方法。
二、实验内容与步骤1.为示例文件AR_process及de_echo文件做注释(1)AR_process代码:clearall;%清除内存变量clearall;%清除内存变量Nn=randn(1,4096);%产生一个1*4096的随机项矩阵NnRn=conv(Nn,fliplr(Nn));%求fliplr(Nn)与Nn的卷积,其中fliplr(Nn)是对Nn进行左右翻转,即噪声功率的时域函数Fn=fft(Rn);%对Rn进行快速傅立叶变换,即求噪声功率的频域表示subplot(2,2,1);plot(abs(Fn));title('噪声功率谱');%绘制噪声功率谱的幅频响应曲线a1=0.1;a2=-0.8;%为a1,a2赋值a=[1,a1,a2];%设定系统频率特性多项式的系数b=1;[H,W]=freqz(b,a,length(Fn),'whole');%系统的频率响应H,频率向量W(单位为弧度).长度与Fn的一致subplot(2,2,2);plot(W,abs(H));title('AR系统幅频特性');%绘制AR系统的幅频特性曲线Fx1=abs(H).^2.*(Fn.');%求AR过程功率谱(输出功率=输入功率乘以H模的平方)subplot(2,2,3);plot(abs(Fx1));title('AR过程功率谱(方法1)');%绘制AR过程功率谱幅频特性曲线h=ifft(H);%求系统的冲激响应x=conv(h,Nn);%h与Nn的离散卷积,即求系统的输出函数(输出=输入*冲激响应)Rx=conv(x,fliplr(x));%求系统输出的时域功率函数Fx2=fft(Rx);%求系统输出的频域功率谱subplot(2,2,4);plot(abs(Fx2));title('AR过程功率谱(方法2)');%绘制AR过程功率谱幅频特性曲线(2)de_echo代码:clearall;%清除内存变量T=1/8000;%设置时间间隔t=0:T:4;%t为以T为间隔的从0到4的一维数组N=length(t);%N为t的长度x=chirp(t,0,1,100);%生成chirp信号,即时间t的调频信号:t=0时频率为0,t=1时频率为100wavplay(x);%播放无回声信号a=1;%确定滤波器的系数a和bb=[1,zeros(1,5999),0.15];%延迟6000个点y=filter(b,a,x);%将原信号和回声混合wavplay(y);%播放回声混音信号z=filter(a,b,y);%逆滤波,消除回声(逆系统函数多项式分子系数为a,分母系数为b)wavplay(z)%播放消除回声信号subplot(3,1,1);plot(abs(fft(x)));%绘制无回声信号的频率响应曲线subplot(3,1,2);plot(abs(fft(y)));%绘制混有回声的信号频率响应曲线subplot(3,1,3);plot(abs(fft(z)));%绘制消除回声后信号的频率响应曲线2.绘制连续信号的波形程序代码为:%1.绘制连续信号波形%x1(t)=sin(200pi*t),x2(t)=cos(200pi*t),0<=t<=0.5;%本题中取4个周期,从0到0.04;clear all;t=0:0.0001:0.04;%取时间间隔x1=sin(200*pi*t);%产生正弦信号x2=cos(200*pi*t);%产生余弦信号plot(t,x1,'-r',t,x2,':b');%绘制正弦(红色)、余弦(蓝色)信号波形grid%输入网格运行结果如下图所示:12()sin(200),()cos(200),00.5x t t x t t t ππ==≤≤3.绘制离散信号的波形程序代码为:%2.绘制离散信号波形%x1=sin(n*pi/4)%x2=(1/2).^(-n)n=-10:1:10;x1=sin(n*pi/4);x2=(1/2).^(-n);figure(1)%指定第一张图H=stem(n,x1,'fill','--');%绘制函数x1的波形,用虚线及实点表示set(get(H,'BaseLine'),'LineStyle',':')set(H,'MarkerFaceColor','red')%给圆圈涂红色grid%输入网格figure(2)%指定第二张图h=stem(n,x2,'fill','--');%绘制函数x2的波形,用虚线及实点表示set(get(h,'Baseline'),'LineStyle',':')set(h,'MarkerFaceColor','red')%给圆圈涂红色grid运行结果如下图所示:121()sin(),()(),1042n x n n x n n π−==≤≤-104.已知)()5.0()(n n h n ε=,)5()()(−−=n n n x εε,求h(n)和x(n)的卷积。
matlab实验报告

matlab实验报告引言:Matlab(矩阵实验室)是一款功能强大的数值计算和科学计算软件,广泛应用于工程、科学和经济等领域。
本实验报告将探讨我在使用Matlab进行实验过程中的心得体会和实验结果。
实验一:图像处理在这个实验中,我使用Matlab对一张图像进行了处理,并应用了各种图像处理算法。
这包括图像增强、边缘检测和图像分割等技术。
通过Matlab的图像处理工具箱,我能够轻松调用各种算法函数,并对图像进行快速处理。
实验结果表明,Matlab图像处理工具箱提供了丰富的函数和算法,极大地方便了我们的图像处理工作。
实验二:模拟信号处理模拟信号处理是Matlab中的一个重要应用领域。
在这个实验中,我模拟了一个带噪声的正弦信号,并使用Matlab进行了噪声滤波和频谱分析。
通过使用Matlab的滤波函数,我能够有效地去除信号中的噪声,并还原出原始信号。
同时,Matlab提供了功能强大的频谱分析工具,我可以轻松地对信号的频率特性进行分析和可视化。
实验三:数据分析与统计数据分析与统计是Matlab的另一个重要应用领域。
在这个实验中,我使用Matlab对一组实验数据进行了分析和统计。
通过使用Matlab的统计函数和工具,我能够计算出数据的均值、方差、标准差等统计指标,并绘制出数据的直方图和散点图。
这些统计分析结果对我的实验研究提供了有力的支持,并帮助我更好地理解实验数据。
实验四:数值计算与优化数值计算与优化是Matlab的核心功能之一。
在这个实验中,我使用Matlab进行了一组数值计算和优化实验。
通过使用Matlab的数值计算函数和优化工具箱,我能够快速计算出复杂的数学问题,并找到最优解。
同时,在进行优化实验时,我可以设置各种约束条件和目标函数,从而得到最优解的参数值。
这些数值计算和优化工具极大地提高了我的研究效率和准确度。
结论:通过这些实验,我深刻认识到Matlab的强大功能和广泛应用领域。
无论是图像处理、信号处理、数据分析还是数值计算与优化,Matlab都提供了丰富的函数和工具,让我们能够快速高效地完成实验和研究工作。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1. 利用符号极限判定函数的连续性。
微积分是数学分析中的一个重要内容,是高等数学建立的基础和整个微分方程体系的基础内容。
Matlab 能够通过符号函数的计算实现微积分运算,如极限、微分、积分、级数等。
极限是当变量无限接近特定值时函数的值,例如,一元函数f(x)的导数f ’
(x)的定义为下面的极限:f ’(x)=h
x 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)= {0
x 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)=-→0
lim x f(x)=- 1/2 =0=f(0), 所以,在x=0时函数是不连续的。
2.在实际应用中,常常提出这样一种需求:把同一自变量的两个不用量纲、不同数量级的函数量的变化绘制在同一张图上。
例如希望在同一张图上表现出温度、湿度随时间的变化;人口数量、GDP 的变化曲线等。
为满足这种需求,Matlab 提供了一下指令:
Plot(x1,y1,x2,y2):以左、右不同纵轴绘制x1-y1、x2-y2两条曲线。
plot(x1,y1,x2,y2,’FUN ’):以左、右不同纵轴把x1-y1、x2-y2绘制成FUN 制定形式的两条曲线。
plot(x1,y1,x2,y2,’FUN1’,’FUN2’):以左、右不同纵轴把x1-y1、x2-y2绘制成FUN1、FUN2制定形式的两条曲线。
例如:画出函数y=xsinx 和积分s=⎰x
dx x x 0)sin ( 在区间[0,4]上的曲线。
求解过程:
● 运用cumtrapz 求累计积分
● 分别采用“杆图”和“线图”绘制被积函数和原函数,并把重合在一起的两张图的“轴对象句柄”赋给a
● <1>和<2>用于合成s=⎰x
dx x x 0)sin (字符串 ● 在plotyy 生成的图形中,使用text 指令加注标识文字的位置是根据左纵轴决定的
命令界面代码和结果如下:
图形如下:
3.M文件编程
编写一个M文件,具有以下功能:(1)根据指定的半径,画出蓝色圆周线;(2)可以通过输入字符串,改变圆周线的颜色和线型;(3)假若需要输出圆面积,则绘出圆。
解答过程:
(1)编写M文件ex1.m
其中,截图部分为隐藏的注释部分为:
% ex1.m the area and perimeter of a regular polygon(正多边形的面积和周长)
% N the number of sides
% R the circumraius
% str a line specification to determine line type % S the area of the regular polygon
% L the perimeter of the regular polygon
% ex1 用蓝实线画半径为1的圆
% ex1(N) 用蓝实线画外接半径为1的正N边形
% ex1(N,R) 用蓝实线画外接半径为R的正N边形
% ex1(N,R,str) 用str指定的线画外接半径R的正N边形
% s=ex1(...) 给出多边形面积S,并画相应正多边形填色图
% [S,L]=ex1(...) 给出多边形面积S和周长L,并画相应正多边形填色
M文件代码如下:
保存M文件,名为ex1.m 。
(2)在指令窗中编写以下代码并运行。
如图显示代码和运行结果:
图形如下:。