materlab实验报告2
MATLAB实验报告
![MATLAB实验报告](https://img.taocdn.com/s3/m/2459908db04e852458fb770bf78a6529647d35b4.png)
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` 函数从外部文件读取数据和将数据保存到文件中。
MATLAB实验报告
![MATLAB实验报告](https://img.taocdn.com/s3/m/c34526744b73f242336c5f91.png)
5、在MATLAB环境下,建立了一个变量fac,同时又在当前目录下建立了一个m文件fac、m,如果需要运行fac、m文件,该如何处理?
实验二MATLAB矩阵及运算
实验目得与要求:
1、掌握MATLAB数据对象得特点及运算规则
2、掌握MATLAB建立矩阵得方法及矩阵处理得方法
实验一MATLAB操作基础
实验目得与要求:
1、熟悉MATLAB得操作环境及基本操作方法。
2、掌握MATLAB得搜索路径及设置方法。
3、熟悉MATLAB帮助信息得查阅方法
实验内容:
1、建立自己得工作目录,再设置自己得工作目录设置到MATLAB搜索路径下,再试验用help命令能否查询到自己得工作目录。
2、在MATLAB得操作环境下验证课本;例1-1至例1-4,总结MATLAB得特点。
m=m1+m2*10+m3*100;
disp(m);
2.输入一个百分制成绩,要求输出成绩等级A、B、C、D、E。其中90~100分为A,80~89分为B,70~79分为C,60~69分为D,60分以下为E。要求:
(1)分别用if语句与switch语句实现
(2)输入百分制成绩后要判断该成绩得合理性,对不合理得成绩应输出出错信息。
disp('E’);
else
disp(’输入出错’);
end
c=input('请输入一个百分制分数:’);
%用switch语句实现
switch fix(c/10);
case{9,10}
m=’A';
case{8}
m=’B';
case{7}
matlab实验报告
![matlab实验报告](https://img.taocdn.com/s3/m/13a34dd649649b6648d74728.png)
Matlab实验报告实验二图像处理一、实验目的(1)通过应用MA TLAB语言编程实现对图像的处理,进一步熟悉MATLAB软件的编程及应用;(2)通过实验进一步掌握图像处理的基本技术和方法。
二、实验内容及代码㈠.应用MA TLAB语言编写显示一幅灰度图像、二值图像、索引图像及彩色图像的程序,并进行相互之间的转换首先,在matlab页面中的current directory下打开存放图像的文件夹。
1.显示各种图像⑴显示彩色图像:①代码:>> mousetif=imread('tif.TIF');>> image(mousetif)显示截图:②代码:>> mousetif=imread('tif.TIF');>> imshow(mousetif)显示截图:③代码:mousetif=imread('tif.TIF');subimage(mousetif)显示截图:显示截图:⑵显示二值图像①代码:>> I=imread('单色bmp.bmp');>> imagesc(I,[0 2])显示截图:②代码:>> I=imread('单色bmp.bmp');>> imshow(I,2)显示截图:③代码:>> I=imread('单色bmp.bmp');>> subimage(I)显示截图:⑶显示灰度图像①代码:>> I1=imread('256bmp.bmp');>> imagesc(I1,[0,256])显示截图:代码:>> I1=imread('256bmp.bmp');>> colormap(gray);>> subplot(1,2,1);>> imagesc(I1,[0,256]);>> title('灰度级为[0 256]的mouse.bmp图');>> subplot(1,2,2);>> imagesc(I1,[0,64]);>> colormap(gray);>> title('灰度级为[0 64]的mouse.bmp图');显示截图:⑷显示索引图像代码:>> mousetif=imread('tif.TIF');>> [x,map]=rgb2ind(mousetif,0.7);>> subplot(1,2,1);>> imshow(mousetif);>> title('彩色图像');>> subplot(1,2,2);>> imshow(x,map);>> title('索引图');截图显示:彩色图像索引图2.图像之间的转换⑴索引图像转灰度图像代码:>> II1=ind2gray(x,map);>> imshow(x,map);>> title('索引图像');>> imshow(II1);>> title('灰度图像');截图显示:索引图像灰度图像⑵ 索引图像转彩色图像⑶ 索引图像转二值图像⑷ 灰度图像转索引图像代码:>> I1=imread('256bmp.bmp');>> subplot(1,2,1);>> imagesc(I1,[0,256]); >> colormap(gray); >> title('灰度图');>> [x,map]=gray2ind(I1,256); >> subplot(1,2,2); >> image(x);>> colormap(map); >> title('索引图');显示截图:灰度图2004006008001000100200300400500600索引图2004006008001000100200300400500600⑸灰度图像转彩色图像⑹灰度图像转二值图像⑺彩色图像转灰度图像⑻彩色图像转索引图像代码:>> mousetif=imread('tif.TIF');>> [x,map]=rgb2ind(mousetif,0.7);>> subplot(1,2,1);>> imshow(mousetif);>> title('彩色图像');>> subplot(1,2,2);>> imshow(x,map);>> title('索引图');显示截图:彩色图像索引图⑼彩色图像转二值图像⑽二值图像转索引图像⑾二值图像转彩色图像⑿二值图像转灰度图像㈡应用MA TLAB工具箱演示一幅图像的傅里叶变换、离散余弦变换,观察其频谱图。
MATLAB实验报告(打印版)
![MATLAB实验报告(打印版)](https://img.taocdn.com/s3/m/1777792658fb770bf78a5539.png)
MATLAB实验报告班别:09电气3班姓名:李嘉明学号:200924122301实验一/二 MATLAB的基础操作3.自定义一个变量,然后分别用8种不同的数字显示格式显示查看。
>> a=[1.1,1.2,1.3;1.4,1.5,1.6;1.7,1.8,1.9]a =1.1000 1.2000 1.30001.4000 1.5000 1.60001.7000 1.8000 1.9000>> format long>> aa =1.100000000000000 1.200000000000000 1.3000000000000001.400000000000000 1.500000000000000 1.6000000000000001.700000000000000 1.800000000000000 1.900000000000000>> format short e>> aa =1.1000e+000 1.2000e+000 1.3000e+0001.4000e+000 1.5000e+000 1.6000e+0001.7000e+000 1.8000e+000 1.9000e+000>> format long e>> aa =1.100000000000000e+000 1.200000000000000e+000 1.300000000000000e+0001.400000000000000e+000 1.500000000000000e+000 1.600000000000000e+0001.700000000000000e+000 1.800000000000000e+000 1.900000000000000e+000 >> format hex>> aa =3ff199999999999a 3ff3333333333333 3ff4cccccccccccd3ff6666666666666 3ff8000000000000 3ff999999999999a3ffb333333333333 3ffccccccccccccd 3ffe666666666666>> format +>> aa =+++++++++>> format rat>> aa =11/10 6/5 13/107/5 3/2 8/517/10 9/5 19/10>> format short>> aa =1.1000 1.2000 1.30001.4000 1.5000 1.60001.7000 1.8000 1.90005、己举例比较给矩阵的全行赋值,取出矩阵中某一个或几个元素,然后组成一个新的矩阵。
matlab实验二实验报告及程序
![matlab实验二实验报告及程序](https://img.taocdn.com/s3/m/1a74d2a5284ac850ad0242bd.png)
昆明理工大学信息工程与自动化学院学生实验报告( 2011——2012 学年 第一学期 )课程名称:控制系统计算机辅助设计 开课实验室:信自楼 234 2011年10月28日年级、专业、班 学号 姓名 成绩实验项目名称 实验二 控制系统分析指导教师 胡蓉教师评语该同学是否熟悉实验内容: A.熟悉□ B.比较熟悉□ C.不熟悉□ 该同学的实验能力: A.强 □ B.中等 □ C.差 □ 该同学的实验是否达到要求 : A.达到□ B.基本达到□ C.未达到□ 实验报告是否规范: A.规范□ B.基本规范□ C.不规范□ 实验过程是否详细记录: A.详细□ B.一般 □ C.没有 □注:5个A 为优,5个B 为中,介于二者间为良,5个C 为不及格,3个B以上为及格。
教师签名:年 月 日实验二 控制系统分析一、 实验目的1. 掌握如何使用Matlab 进行系统的时域分析。
2. 掌握如何使用Matlab 进行系统的频域分析。
3. 掌握如何使用Matlab 进行系统的根轨迹分析。
4. 掌握如何使用Matlab 进行系统的稳定性分析。
二、 实验内容1.时域分析(1)典型二阶系统传递函数为:当ζ=0.7, ω取2、4、6、8、10、12的单位阶跃响应。
n程序为:>> num1=4;den1=[1,2.8,4];sys1=tf(num1,den1);>> num2=16;den2=[1,5.6,16];sys2=tf(num2,den2);>> num3=36;den3=[1,8.4,36];sys3=tf(num3,den3);>> num4=64;den4=[1,11.2,64];sys4=tf(num4,den4);>> num5=100;den5=[1,14,100];sys5=tf(num5,den5);>> num6=144;den6=[1,16.8,144];sys6=tf(num6,den6);>> step(sys1,sys2,sys3,sys4,sys5,sys6);运行单位阶跃响应结果图为:(2)典型二阶系统传递函数为:当ω=6, ζ取0.2、0.4、0.6、0.8、1.0、1.5、2.0的单位阶跃响应。
matlab课内实验报告(二)
![matlab课内实验报告(二)](https://img.taocdn.com/s3/m/1017fb1ba6c30c2259019e23.png)
《matlab》课内实验报告姓名:徐永凯学号:2012309020107学院:理学院班级:数学121课程名称:matlab实验题目:matlab指导教师:王冠2013年09月26日一、实验目的1.掌握Matlab 的流程控制;2.了解Gauss-Seidel 迭代求解线性代数方程组和Newton 迭代求解非线性方程的算法;3.掌握Matlab 程序设计的基本过程。
二、实验内容和结果1.利用Gauss-Seidel 迭代求解线性代数方程组。
Gauss-Seidel 迭代公式b L Ux L x k k 1)(1)1(--++-=,其中L 是系数矩阵A 的下三角矩阵(含主对角线),U 是系数矩阵A 的上三角矩阵(不含主对角线)。
function [x1,i]=gs(A,b,x0)clc L=tril(A);U=triu(A)-diag(diag(A));p=-(inv(L)*U);q=(inv(L))*b;for i=1:500x1=p*x0+q;x0=x1;if norm(A*x0-b)<1e-6break ;end end2.利用Newton 迭代求解非线性方程。
Newton 迭代公式)()('11k k k k x f x f x x -+-=,其中待求解方程为0)(=x f 。
function y=Newton(f1)sysm x1f2x2f1=x1-sin(x1);f2=diff(f1,x1,1);x2=x1-f2\f1;x0=3;for i=1:500x=subs(x2,x1,x0);if (abs(x-x0))<1e-6break;endendx0=x;end三、思考及总结对迭代法有了初步的了解,感觉matlab中的函数有好多,对于函数的应用还有待加强;。
MATLAB试验报告
![MATLAB试验报告](https://img.taocdn.com/s3/m/3dad2841be1e650e52ea99b5.png)
实验二初试MATLAB一、实验目的1.熟悉视窗下的MATLAB环境;2.掌握MATLAB软件的基本使用方法;3.应用MATLAB命令建立系统数学模型;4.掌握利用MATLAB软件进行控制系统模型转换的方法。
二、实验属性(验证性)三、实验仪器设备及器材1.硬件要求基于IBM-PC或与之完全相兼容的带有中央处理器的奔腾及其以上机器至少64KB内存,推荐使用128KB以上内存。
2.软件要求安装有MATLAB,并且有Microsoft Word7.0(office95)以上支持的操作系统。
四、实验要求实验前要求熟悉相关MATLAB函数并预习实验的相关内容,写出预习报告。
实验时要按要求完成上机实验内容并且检验和调整程序,观察并记录仿真结果。
实验后写出实验报告,并对仿真实验结果进行分析、讨论。
五、实验内容与步骤1.双击MATLAB6.5的图标,运行MATLAB时,展示在用户面前的为桌面环境的缺省界面窗口,如图2-1所示。
图2-1 MATLAB的桌面环境要求熟悉视窗下的MATLAB环境,分别观察和熟悉菜单项、工具栏、历史命令窗口、命令窗口、当前目录浏览器、工作空间浏览器、目录分类窗口、M文件编辑器/调试器、超文本帮助浏览器。
2.单击工具栏中帮助按钮(或者单击Help菜单中的MATLAB Help),打开MATLAB6.5的帮助系统,练习和熟悉MATLAB6.5的帮助系统的使用。
3.应用MATLAB命令编写相应M文件,建立图2-2系统的数学模型——闭环传递函数。
图2-2 调速系统g1=tf(1,[0.01,1]);g2=tf([0.17,1],[0.085,0]);g3=g1;g4=tf([0.15,1],[0.05,0]);g5=tf(70,[0.0067,1]);g6=tf(0.21,[0.15,1]);g7=tf(130,[1,0]);g11=feedback(g6,0.01*g4*g5*g1);g22=feedback(g1*g7,0.212);g33=feedback(g2*g3*g4*g5*g22,0.0044*g1);g=g1*g33Transfer function:2.321 s^3 + 261.2 s^2 + 3003 s + 9100--------------------------------------------------------------- 2.848e-013 s^8 + 1.564e-010 s^7 + 3.487e-008 s^6 + 4.042e-006 s^5 + 0.0002572 s^4 + 0.01876 s^3 + 1.266 s^2+ 13.21 s + 40.04实验三 基于MATLAB 的系统时域分析一、实验目的1.熟悉MATLAB 的各种绘图命令;2.掌握基于MATLAB 的控制系统时域分析方法。
MATLAB实验报告(2)
![MATLAB实验报告(2)](https://img.taocdn.com/s3/m/9487e8fc5122aaea998fcc22bcd126fff7055d06.png)
MATLAB实验报告(2)广西大学实验报告纸姓名:徐律1002100405电气工程学院自动化102班2012年12月27日【实验名称】MATLAB的图形绘制【实验要求】1、学习MATLAB图形绘制的基本方法;2、熟悉和了解MATLAB图形绘制程序编辑的基本指令;3、熟悉掌握利用MATLAB图形编辑窗口编辑和修改图形界面,并添加图形的各种标注;4、掌握plot、subplot的指令格式和语法。
【实验基本知识】1、plot(x,y)------绘制由x,y所确定的曲线;2、多组变量绘图:plot(x1, y1, 选项1, x2, y2, 选项2, ……);3、双Y轴绘图:plotyy()函数;4、图形窗口的分割;5、图形编辑窗口的使用。
【实验内容】【1】二维曲线绘图基本指令演示。
本例运作后,再试验plot(t), plot(Y), plot(Y,t) ,以观察产生图形的不同。
t=(0:pi/50:2*pi)';k=0.4:0.1:1;Y=cos(t)*k;plot(t,Y)plot(t,Y); plot(t);plot(Y);plot(Y,t); %图形如下图所示【2】用图形表示连续调制波形Y=sin(t)sin(9t)及其包络线。
t=(0:pi/100:pi)';y1=sin(t)*[1,-1];y2=sin(t).*sin(9*t);t3=pi*(0:9)/9;y3=sin(t3).*sin(9*t3);plot(t,y1,'r:',t,y2,'b',t3,y3,'bo')axis([0,pi,-1,1])【3】在一个图形窗口绘制正弦和余弦曲线,要求给图形加标题“正弦和余弦曲线”,X轴Y轴分别标注为“时间t”和“正弦、余弦”,在图形的某个位置标注“sin(t)”“cos(t)”,并加图例,显示网格,坐标为正方形坐标系。
实验程序:实验结果:Sin(t)Cos(t)【4】绘制向量x=[1 3 0.5 2.5 2]的饼形图,并把3对应的部分分离出来。
MATLAB实验报告(8个实验)
![MATLAB实验报告(8个实验)](https://img.taocdn.com/s3/m/4bb78d3a5acfa1c7ab00cc3a.png)
四川师范大学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实验报告2
![MATLAB实验报告2](https://img.taocdn.com/s3/m/911a2b3253d380eb6294dd88d0d233d4b14e3fc1.png)
MATLAB实验报告2实验(2)Matlab 基础操作实验:符号运算求解微积分与线性代数1. 求下列函数极限(Find the limits of the following functions )(1) 0sin lim x xx →syms x r ;r=sin(x)/x;limit(r,x,0)ans =1(2) 1lim(1)x x x →∞+syms x r ;r=(1+1/x)^x;limit(r,x,inf)ans =exp(1) (3) lim (1)xx a x →+∞+syms x r a ;r=(1+a/x)^x;limit(r,x,inf)ans =exp(a)(4) 1lim (1)xx x →-∞+syms x r ;r=(1+1/x)^x;limit(r,x,-inf)ans =exp(1) (5)201cos lim x xx →-syms x r ;r=(1-cos(x))/(x^2);limit(r,x,0)ans =实验(2)Matlab 基础操作实验:符号运算求解微积分与线性代数1/2(6) lim nsyms n r ;r=n^(1/n);limit(r,n,inf)ans =1(7)0lim x x π+→ syms x n r ;r=(cos(sqrt(x)))^(n/x);limit(r,x,0,'right')ans =1/exp(n/2)2.求下列函数的导数或偏导数( Find the derivatives of the following functions)(1)()()f x g x ==syms x a b c f g ;f=sqrt(a*x^2+b*x+c);g=sqrt(exp(x^2)+x*sin(x));a1=diff(f,x)a2=diff(g,x)a1 =(b + 2*a*x)/(2*(a*x^2 + b*x + c)^(1/2))a2 =(sin(x) + 2*x*exp(x^2) + x*cos(x))/(2*(exp(x^2) + x*sin(x))^(1/2))(2)3()ln()f x x =syms x f ;f=log(x^3);实验(2)Matlab基础操作实验:符号运算求解微积分与线性代数diff(f,x)ans =3/x(3)Find the 3rd derivative of f(x).()f x=2xxe-syms x f;f=x*exp(-x^2);diff(f,x,3)ans =(24*x^2)/exp(x^2) - 6/exp(x^2) - (8*x^4)/exp(x^2) (4) )Find23222(235)x x y yx-+-?syms x y f;f=x^3-2*x^2*y^2+3*y-5; diff(f,x,2)ans =6*x - 4*y^2(5)Find2322(235)x x y yx y-+-.syms x y f;f=x^3-2*x^2*y^2+3*y-5;fx=diff(f,x);fxy=diff(fx,y)fxy =-8*x*y3. 求下列函数的不定积分或定积分(Find indefinite integrals or definite integrals of the functions)(1)1(sin2cos3)xx x e dxx--++syms x s;s=sin(x)-2*cos(3*x)+1/x+exp(-x); int(s,x)ans =实验(2)Matlab 基础操作实验:符号运算求解微积分与线性代数log(x) - (2*sin(3*x))/3 - cos(x) - 1/exp(x)(2)sin()x x e e dx ?syms x s ;s=exp(x)*sin(exp(x));int(s,x)ans =-cos(exp(x))(3)2syms x s ;s=x^2/(sqrt(x^6)+4);int(s,x)Warning: Explicit integral could not be found.ans =int(x^2/((x^6)^(1/2) + 4), x)(4)cos3cos5x xdx ?syms x s ;s=cos(3*x)*cos(5*x);int(s,x) ans =sin(2*x)/4 + sin(8*x)/16(5) syms x s a ;s=(sqrt(x^2-a^2))/x;int(s,x)ans =实验(2)Matlab 基础操作实验:符号运算求解微积分与线性代数(x^2 - a^2)^(1/2) - log(((-a^2)^(1/2) + (x^2 -a^2)^(1/2))/x)*(-a^2)^(1/2)(6) sin ax e bxdx ?syms x s a b ;s=exp(a*x)*sin(b*x);int(s,x)ans =-(exp(a*x)*(b*cos(b*x) - a*sin(b*x)))/(a^2 + b^2) (7) 0πsyms x s ;s=sqrt(sin(x)-(sin(x))^3);int(s,x,0,pi)Warning: Explicit integral could not be found.ans =int((sin(x) - sin(x)^3)^(1/2), x = 0..pi) (8) 211dx x +∞? syms x s ;s=1/(x^2);int(s,x,1,inf)14. 解下列方程(Solve the equations.)x =syms x ;solve(sqrt(1-x^2)-x,x)ans =2^(1/2)/2实验(2)Matlab基础操作实验:符号运算求解微积分与线性代数(2)1024x y zx y zx y z++=-+=--=-syms x y z;s=solve(x+y+z-10,x-y+z,2*x-y-z+4,x,y,z) s.x,s.y,s.z s =x: [1x1 sym]y: [1x1 sym]z: [1x1 sym]2ans =5ans =3(3)240330sin0x xy zx yzy z++=+-=+=syms x y z;s=solve(x^2+4*x*y+z,x+3*y*z-3,y+sin(z),x,y,z) s.x,s.y,s.z s =x: [1x1 sym] y: [1x1 sym] z: [1x1 sym]实验(2)Matlab 基础操作实验:符号运算求解微积分与线性代数ans =-6.4840528860501102693511549985753ans =-0.071995758403084664887655346911159ans =-43.9102390493223146672631539563435. 求解下列常微分方程(Solve the following ordinary differential equations.)(1)ln()xy y xy y '=-syms x y ;s=dsolve('x*Dy=y*log(x*y)-y','x')s =1/xexp(exp(C8 + log(x)))/x (2)20(1)5dv t dt v ?+==? syms v t ;s=dsolve('Dv+2*t=0','v(1)=5','t')s =6 - t^2(3)()0y a b y aby '''-++=syms a b x y ;s=dsolve('D2y-(a+b)*Dy+a*b*y=0','x')s =实验(2)Matlab 基础操作实验:符号运算求解微积分与线性代数C13*exp(a*x) + C14*exp(b*x)6. 用MATLAB 验证(Use MALTAB to prove the following identities)(1) 22sin cos 1x y +=syms x ;s=solve((sin(x))^2+cos((x))^2-1,x)s =C_求解此方程所得的解是全体实数因此该等式在实数域上成立。
MATLAB实验报告(8个实验)
![MATLAB实验报告(8个实验)](https://img.taocdn.com/s3/m/69a3ae0e55270722192ef7c5.png)
3 Exercises Please solve the following problems in MATLAB. Do not forget to keep a diary of your commands and their outputs.
(1) Define the variables x y and z as 7.6, 5.5 and 8.1, respectively, and evaluate:
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,
2 Using MATLAB 2.1 Starting MATLAB Logon 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.
2 Script Files Script 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.
Matlab实验报告
![Matlab实验报告](https://img.taocdn.com/s3/m/bca02db3cc7931b764ce157e.png)
实验结果及分析实验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实习实验报告
![matlab实习实验报告](https://img.taocdn.com/s3/m/b8459eac84868762caaed564.png)
实验一时间序列ARMA学习一、基本形式ARMA模型分为以下三种:1.自回归模型(AR)如果时间序列满足其中是独立同分布的随机变量序列,且满足:以及E( ) = 0,则称时间序列为服从p阶的自回归模型。
AR模型是用过去的观测值和现在的干扰值的线性组合来预测未来值,式子中的p为阶数,β为待定参数,y为一个平稳序列。
自回归模型的平稳条件:滞后算子多项式的根均在单位圆外,即φ(B) = 0的根大于1。
2.移动平均模型(MA)如果时间序列满足则称时间序列为服从q阶移动平均模型;MA模型是用过去的干扰值和现在的干扰值的线性组合预测未来的值,式中q为阶数,α为待定参数,y为一个平稳序列。
移动平均模型平稳条件:任何条件下都平稳。
3.自回归滑动平均模型(ARMA)如果时间序列满足:则称时间序列为服从(p,q)阶自回归滑动平均混合模型。
模型求解流程图:二、实例分析太阳的光球表面有时会出现一些暗的区域,它是磁场聚集的地方,这就是太阳黑子。
黑子是太阳表面可以看到的最突出的现象。
一个中等大小的黑子大概和地球的大小差不多。
长期的观测发现,黑子多的时候,其他太阳活动现象也会比较频繁。
从外文网站查询到太阳黑子数量的变化,从而预测接下来数量的走势。
首先整理数据,进行平稳性判断,使用matlab语言中的adftest()函数即可。
数据为平稳数据,因而无需做平稳化处理,使用AR模型对原数据作出预测。
Matlab代码为:clccleara=csvread('heizi.csv');b=a(2700:3234,[1,4]);c=b(:,2);diff(c);adftest(c)%figure(2);subplot(2,1,1)autocorr(c,500)%²set(gca,'Xlim',[0 500]);subplot(2,1,2)parcorr(c,50);set(gca,'Xlim',[0 50]);z=iddata(c);%×m=armax(z(1:end),'na',20,'nc',0);%yp = predict(m,c,1);figure(3)plot(c,'-.');hold onplot(yp,'r')gridlegend('³õʼֵ','Ô¤²âÖµAR')bzc=sum((yp-c).^2)结果如下:2.MA模型求解Matlab代码:clccleara=csvread('heizi.csv');b=a(2700:3234,[1,4]);c=b(:,2);diff(c);adftest(c)figure(2);subplot(2,1,1)autocorr(c,500)set(gca,'Xlim',[0 500]);subplot(2,1,2)parcorr(c,50);set(gca,'Xlim',[0 50]);z=iddata(c);m=armax(z(1:end),'na',0,'nc',4); yp = predict(m,c,1);figure(3)plot(c,'-.');hold onplot(yp,'r')gridlegend('³õʼֵ','Ô¤²âÖµMA')bzc=sum((yp-c).^2)结果如下:3.ARMA模型求解对于ARMA模型,需要做出阶数判断,用ACF和PACF确定p、q阶数,在使用ARMA模型求解。
(2021年整理)Matlab实验报告
![(2021年整理)Matlab实验报告](https://img.taocdn.com/s3/m/8cf3f79969eae009591becdb.png)
Matlab实验报告编辑整理:尊敬的读者朋友们:这里是精品文档编辑中心,本文档内容是由我和我的同事精心编辑整理后发布的,发布之前我们对文中内容进行仔细校对,但是难免会有疏漏的地方,但是任然希望(Matlab实验报告)的内容能够给您的工作和学习带来便利。
同时也真诚的希望收到您的建议和反馈,这将是我们进步的源泉,前进的动力。
本文可编辑可修改,如果觉得对您有帮助请收藏以便随时查阅,最后祝您生活愉快业绩进步,以下为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命令窗口进行简单数学运算。
[IT计算机]MATLAB实验报告
![[IT计算机]MATLAB实验报告](https://img.taocdn.com/s3/m/1286c93d4a35eefdc8d376eeaeaad1f34693113e.png)
MATLAB实验报告姓名:学号:班级:专业:指导老师:实验一MATLAB运算基础一、实验目的:1、熟悉启动和退出MATLAB的方法。
2、熟悉MATLAB命令窗口的组成。
3、掌握建立矩阵的方法、4、掌握MATLAB各种表达式的书写规则以及常用函数的使用。
二、实验内容:1.1、>> t=0:0.5:2.5t =0 0.5000 1.0000 1.5000 2.0000 2.5000>>y=t.^2.*((t>=0)&(t<1))+(t.^2-1).*((t>=1)&(t>=1)&(t<2))+(t.^2-2*t+1).*((t>=2)&(t <3))y =0 0.2500 0 1.2500 1.0000 2.2500分析:该实验用逻辑表达式求出了分段函数的值。
1.2、>> p=rem([100:999],21)==0;>> sum(p)ans =43>> p1=rem([100:999],21),A=find(p1==0),length(A)ans =43分析:该实验求出了[100,999]之间能被21整除的数的个数为43.1.3、>> ch='ABcdefGHd',k=find(ch>='A'&ch<='Z'),ch(k)=[]ch =ABcdefGHdk =1 2 7 8ch =cdefd分析:该实验建立了一个字符串向量,删除了其中的大写字母。
1.4、A=[1 2 3;4 5 6;7 8 9],[i,j]=find(A>=5),for n=1:length(i)m(n)=A(i(n),j(n))endm>> mm =7 5 8 6 9分析:该实验求出了矩阵A中大于或等于5的元素为7 5 8 6 9.1.5、>>a11=input('all='),a12=input('a12='),a21=input('a21='),a22=input('a22='),A=[a 11,a12;a21,a22],DA=det(A),IN=inv(A),EA=eig(A)a11=23a12=12a21=11a22=32A =23 1211 32DA =604IN =0.0530 -0.0199-0.0182 0.0381EA =15.161039.8390分析:该实验求出了矩阵A中的行列式的值、逆和特征值。
matlab实验报告实验二
![matlab实验报告实验二](https://img.taocdn.com/s3/m/e631f0b47d1cfad6195f312b3169a4517623e54d.png)
matlab实验报告实验二Matlab实验报告实验二引言Matlab是一种功能强大的数学软件,广泛应用于科学研究和工程实践中。
在实验二中,我们将探索Matlab的图像处理功能,并通过实际案例来展示其应用。
图像处理基础图像处理是指对图像进行数字化处理的过程,其目的是改善图像质量、提取有用信息或实现特定的应用需求。
在Matlab中,我们可以利用各种函数和工具箱来实现图像处理的各种任务,如图像增强、滤波、分割和特征提取等。
实验步骤1. 图像读取与显示在Matlab中,我们可以使用imread函数读取图像文件,并使用imshow函数将图像显示在屏幕上。
例如,我们可以读取一张名为"lena.jpg"的图像,并显示出来:```matlabimg = imread('lena.jpg');imshow(img);```2. 图像灰度化图像灰度化是将彩色图像转换为灰度图像的过程。
在Matlab中,我们可以使用rgb2gray函数将彩色图像转换为灰度图像。
例如,我们可以将上一步读取的图像转换为灰度图像:```matlabgray_img = rgb2gray(img);imshow(gray_img);```3. 图像二值化图像二值化是将灰度图像转换为二值图像的过程,其中只包含黑色和白色两种颜色。
在Matlab中,我们可以使用imbinarize函数将灰度图像二值化。
例如,我们可以将上一步得到的灰度图像二值化:```matlabbinary_img = imbinarize(gray_img);imshow(binary_img);```4. 图像平滑图像平滑是指去除图像中的噪声或细节,使得图像更加平滑和清晰。
在Matlab 中,我们可以使用imfilter函数对图像进行平滑处理。
例如,我们可以对上一步得到的二值图像进行平滑处理:```matlabsmooth_img = imfilter(binary_img, fspecial('average'));imshow(smooth_img);```5. 图像边缘检测图像边缘检测是指提取图像中物体边缘的过程,常用于目标检测和图像分割。
matlab数学实验报告2
![matlab数学实验报告2](https://img.taocdn.com/s3/m/68d55af9240c844769eaeede.png)
数学实验报告2011年6月12日培养容器温度变化率模型一、实验目的利用matlab软件估测培养容器温度变化率二、实验问题现在大棚技术越来越好,能够将温度控制在一定温度范围内。
为利用这种优势,实验室现在需要培植某种适于在8.16℃到10.74℃下能够快速长大的甜菜品种。
为达到实验所需温度,又尽可能地节约成本,研究所决定使用如下方式控制培养容器的温度:1,每天加热一次或两次,每次约两小时;2,当温度降至8.16℃时,加热装置开始工作;当温度达到10.74℃时,加热装置停止工作。
已知实验的时间是冬天,实验室为了其它实验的需要已经将实验室的温度大致稳定在0℃。
下表记录的是该培养容器某一天的温度34三、 建立数学模型1, 分析:由物理学中的傅利叶传热定律知温度变化率只取决于温度差,与温度本身无关。
因为培养容器最低温度和最高温度分别是:8.16℃和10.74℃;即最低温度差和最高温度差分别是:8.16℃和10.74℃。
而且,16.8/74.10≈1.1467,约为1,故可以忽略温度对温度变化率的影响2, 将温度变化率看成是时间的连续函数,为计算简单,不妨将温度变化率定义成单位时间温度变化的多少,即温度对时间连续变化的绝对值(温度是下降的),得到结果后再乘以一系数即可。
四、 问题求解和程序设计流程 1) 温度变化率的估计方法根据上表的数据,利用matlab 做出温度-时间散点图如下:下面计算温度变化率与时间的关系。
由图选择将数据分三段,然后对每一段数据做如下处理:设某段数据为{(0x ,0y ),(1x ,1y ),(2x ,52y ),…,( n x ,n y )},相邻数据中点的平均温度变化率采取公式:温度变化率=(左端点的温度-右端点的温度)/区间长度 算得即:v(21ii x x ++)=(1+-i i y y )/(i i x x -+1).每段首尾点的温度变化率采用下面的公式计算: v(0x )=(30y -41y +2y )/(2x -0x ) v(n x )=(3n y -41+n y +2+n y )/(n x -2-n x )用以上公式计算得温度变化率与时间的数据表如下:下面分别利用数据插值法和数据拟合法两种方法来估计温度变化率1)数据插值法对上表即温度变化率与时间的数据表加热装置不工作时段1和加热装置不工作时段2采用插值法,可以得到任意时刻的温度变化率;编写matlab程序如下:t=[0,0.46,1.38,2.395,3.41,4.425,5.44,6.45,7.465,8.45,8.97];v=[29.89,21.74,18.48,16.22,16.30,15.32,13.04,15.45,13.98,16.35,19.27];t0=0:0.1:8.97;lglr=lglrcz(t,v,t0);lglrjf=0.1*trapz(lglr)fdxx=interp1(t,v,t0);fdxxjf=0.1*trapz(fdxx)scyt=interp1(t,v,t0,'spline');sancytjf=0.1*trapz(scyt)plot(t,v,'*',t0,lglr,'r',t0,fdxx,'g',t0,scyt,'b')gtext('lglr')gtext('fdxx')6gtext('scyt')其中使用了lglrcz.m文件lglrcz.m的代码是:function y=lglrcz(x0,y0,x)n=length(x0);m=length(x);for i=1:mz=x(i);s=0.0;for k=1:np=1.0;for j=1:nif j~=kp=p*(z-x0(j))/(x0(k)-x0(j));endends=p*y0(k)+s;endy(i)=s;end程序执行后显示结果:如图曲线lglr,fexx,scyt分别表示用拉格朗日插值法,分段线形插值法和三次样条插值法对第一加热时段数据插值得到的温度变化率-时间线。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
实验二离散信号与系统及其MATLAB实现姓名:蔡红亮学号:2010156203指导老师孙水发
一、实验目的
1.进一步了解matlab6.5应用环境;
2.练习利用matlab6.5中的命令或程序对离散信号和离散时间系
统进行分析---单位样值响应、频率响应、零极点增益分析等。
3.进一步练习matlab6.5中的绘图方法;
4.进一步练习matlab6.5中信号的描述及运算方法;
5.进一步练习M-File的建立、保存、调用。
二、实验原理与方法
1.对离散信号和离散时间系统进行分析的有关公式。
相关函数:
频谱绘制函数:1、freqs;2、freqz;
绘图函数:1、disp;2、grid;
其他函数:
logspace
impz
zplane
Filter
Exp
Real
Imag
Abs
Angle
三、练习作业
已知一因果的LTI系统的系统函数为
H(z)=(8-4z-1+11z-2-2z-3)/(1-1.25z-1+0.75z-2-0.125z-3)。
1)绘制它的幅频相频特性;
2)绘制系统的脉冲响应序列;
3)绘制输入x(n)={1,1,1,1}时系统的输出y(n)。
程序:
b=[8-411-2];a=[1-1.250.75-0.125];
figure(1);
%计算数字波器的频率响应
freqz(b,a,128);
figure(2);
subplot(211);
%计算数字波器的冲激响应
impz(b,a,50);subplot(212);
%显示离散时间系统的零极点图
zplane(b,a);
b=[8-411-2];a=[1-1.250.75-0.125];
figure(1);%计算数字波器的频率响应
freqz(b,a,128);
figure(2);
subplot(211);%计算数字波器的冲激响应impz(b,a,50);subplot(212);
%显示离散时间系统的零极点图
zplane(b,a);
n1=0:3;x=[1111];
figure(3);
stem(n,y);title(‘响应序列’);
0510********
354045
n (samples) A m p l i t u d e Impulse Response
-3-2-10
123
-1
-0.5
00.5
1
Real Part I m a g i n a r y P a r t -10-50510152025响应序列
评分人:丁务曌分数:9。