MATLAB报告范例
- 格式:doc
- 大小:233.50 KB
- 文档页数:14
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、己举例比较给矩阵的全行赋值,取出矩阵中某一个或几个元素,然后组成一个新的矩阵。
《高等数学》实验报告(二)实验项目名称:多元函数积分学分组第八组组员姓名学号专业班级实验软件Matlab2010b完成日期实验成绩一、实验目的:加强对Matlab 软件的基本操作,会利用符号计算中int 积分嵌套命令求二重积分、三重积分。
会合理运用int 嵌套命令求解第一类、第二类曲线积分及第一类、第二类曲面积分以及Green 公式及Gauss 公式解题。
结合已经学习的内容,学会分析上述有关内容的综合问题并利用软件给出正确的解答。
二、 实验内容、步骤与结果:8. 计算二重积分 arctan D y d xσ⎰⎰ 其中D 是由圆224x y += 、 及直线y=0, y=x 所围成的在第一象限内的闭区域。
>> syms x y rho theta>> i=int(int(atan(tan(theta))*rho,rho,1,2),theta,0,(0.25)*pi)i =(3*pi^2)/6418. 计算三重积分 e x y z dxdydz ++Ω⎰⎰⎰,其中, 是平面x+y+z=1与三个坐标面围成的立体。
>> syms x y z;>> i=int(int(int(exp(x+y+z),z,0,1),y,0,1-x),x,0,1)i =exp(1) - 128. 计算曲线积分 2()()L x y dx x y dy ++-⎰,其中,L 沿直线从(1,0) 到(0,1), 再沿直线从(0,1)到(-1,0)。
过程syms x y;p=x^2+y;q=x-y;fun=(x^2+y)*diff(p,x)+(x-y)*diff(q,y);I=int(fun,x,1,0);I=int(fun,y,0,1)I =1/2+2*x^3I=int(fun,x,0,-1);I=int(fun,y,1,0)I =-1/2-2*x^3结果由(1,0)到(0,1)I =1/2+2*x^3由(0,1)到(-1,0)I =-1/2-2*x^338求半径为a的球面面积。
MATLAB课程设计院(系)数学与计算机学院专业信息与计算科学班级学生姓名学号指导老师赵军产提交日期实验内容: 1. Taylor逼近的直观演示用Taylor 多项式逼近y = sin x.已知正弦函数的Taylor 逼近式为∑=----=≈nkk kkxxPx1121!)12()1()(sin.实验目的:利用Taylor多项式逼近y = sin x,并用图形直观的演示。
实验结果报告(含基本步骤、主要程序清单、运行结果及异常情况记录等):1.将k从1取到5,得到相应的P = x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9;2.用MATLAB进行Taylor逼近,取x的范围是(-3.2,3.2);程序清单如下:syms x; y = sin(x); p = x - (x^3)/6 + (x^5)/120 - (x^7)/5040 + (x^9)/362880 x1 = -3.2:0.01:3.2;ya = sin(x1);y1 = subs(p,x,x1);plot(x1,ya,'-',x1,y1)4.程序运行正常。
思考与深入:取y = sin x 的Taylor 多项式为P 的逼近效果很良好,基本接近y = sin x 的图像,不过随着k 的取值变多,逼近的效果会越来越好。
实验内容: 2. 数据插值在(,)[8,8][8,8]x y =-⨯-区域内绘制下面曲面的图形:2222sin()x y z x y+=+并比较线性、立方及样条插值的结果。
.实验目的:学会用MATLAB对函数进行线性、立方及样条插值,并比较结果。
实验结果报告(含基本步骤、主要程序清单、运行结果及异常情况记录等):1.用MATLAB一次进行对函数的线性、立方、及样条插值,并进行算法误差分析。
2.主要程序如下:[x,y] = meshgrid(-8:1:8,-8:1:8);z = sin((x.^2 + y.^2).^0.5)./((x.^2 + y.^2).^0.5);surf(x,y,z),axis([-8,8,-8,8,-2,3])title('z的曲面图形'); %画出z的曲面图形%选较密的插值点,用默认的线性插值算法进行插值figure;[x1,y1] = meshgrid(-8:0.4:8,-8:0.4:8);z1=interp2(x,y,z,x1,y1);surf(x1,y1,z1),axis([-8,8,-8,8,-2,3])title('线性插值');%立方和样条插值figure;z1=interp2(x,y,z,x1,y1,'cubic');z2=interp2(x,y,z,x1,y1,'spline');surf(x1,y1,z1),axis([-8,8,-8,8,-2,3])title('立方插值');figure;surf(x1,y1,z2),axis([-8,8,-8,8,-2,3])title('样条插值');%算法误差的比较z = sin((x1.^2 + y1.^2).^0.5)./((x1.^2 + y1.^2).^0.5);figure;title('误差分析1');figure;surf(x1,y1,abs(z-z2)),axis([-8,8,-8,8,0,0.025]) title('误差分析2');3.结果如下:4.程序运行正常。
MATLAB_实习报告范文大全第一篇:MATLAB_实习报告实习报告实习题目:专业:学号:的设计与绘图MATLAB 一.概述MATLAB 作为一种高级科学计算软件,是进行算法开发、数据可视化、数据分析以及数值计算的交互式应用开发环境。
世界上许许多多的科研工作者都在使用 MATLAB 产品来加快他们的科研进程,缩短数据分析和算法开发的时间,研发出更加先进的产品和技术。
二.实验目的1.进一步熟悉MATLAB的软件环境和基本使用方法;2.巩固运用MATLAB、矩阵运算、多项式运算、字符串、单元数组、符号计算功能、绘图及句柄图形及它们的命令语句;3.学习和巩固数字图形图像处理在MATLAB中的知识和运用;4.培养我们独立自学、设计和撰写实验报告的能力;5.通过对MATLAB的进一步学习,是我们加深所学内容的认识,理解,掌握,能把所学知识运用到实际工作中;三.实习日记1.熟悉MATLAB的软件环境和基本使用方法(第一周)MATLAB的语言的基本功能和特点:它是一种高级科学计算语言,相对于传统的C、C++ 或者FORTRAN 语言,MATLAB 提供了高效快速解决各种科学计算问题的方法。
它具有数学计算、开发工具、数据的可视化、交互式编辑创建图形、集成的算法开发编程语言和环境、图形用户界面开发环境——GUIDE、开放性、可扩展性强、专业应用工具箱等强大的功能。
具有易于学习、使用方便、支持多种操作系统、丰富的内部函数、强大的图形和符号功能等优点。
路径设置:除 MATLAB 默认的搜索路径外,用户可以设置搜索路径。
设置方法为:选择 MATLAB 窗口中的 File | Set Path 命令,进入路径搜索对话框。
MATLAB 的搜索顺序:当在命令窗口中或者一个 M 文件中输入一个元素名时,MATLAB 按照下面的顺序搜索该元素的意义,以元素foo 为例:1)查找工作区中是否存在名为 foo 的变量; 2)在当前路径中查找是否存在名 foo.m 的文件;3)按照顺序查找搜索路径中是否存在该文件。
MATLAB实验报告模板实验题目:使用MATLAB进行数字信号处理实验目的:1. 学习MATLAB的基本操作和数字信号处理中常用的函数。
2. 掌握数字信号的离散化、采样、量化等处理方法。
3. 实现数字滤波器的设计和应用。
实验内容:1. 生成并绘制一个正弦波信号,包括频率、幅度和相位等参数。
2. 对信号进行采样,并绘制采样后的离散信号图像。
3. 对采样后的信号进行量化,并绘制量化后的信号图像。
4. 设计一个数字滤波器,并将滤波前后的信号图像进行对比。
实验步骤:1. 生成一个正弦波信号:```matlab% 信号频率为3Hz,幅度为2,相位为0t = 0:0.01:1;f = 3;A = 2;theta = 0;x = A * sin(2*pi*f*t + theta);```2. 绘制信号图像:```matlabplot(t, x);xlabel('时间');ylabel('幅度');title('正弦波信号');```3. 进行信号的采样:```matlab% 采样频率为20Hzfs = 20;Ts = 1/fs;n = 0:Ts:1;xs = A * sin(2*pi*f*n + theta);```4. 绘制采样信号图像:```matlabstem(n, xs);xlabel('时间');ylabel('幅度');title('采样信号');```5. 进行信号的量化:```matlab% 将信号量化为8位bits = 8;delta = (2 * A) / (2^bits);xq = floor(xs / delta + 0.5) * delta;```6. 绘制量化信号图像:```matlabstem(n, xq);xlabel('时间');ylabel('幅度');title('量化信号');```7. 设计数字滤波器:```matlab% 采用FIR滤波器,截止频率为4Hz fcut = 4;n = 100; % 滤波器阶数b = fir1(n, 2*fcut/fs);y = filter(b, 1, xq);```8. 绘制滤波前后的信号图像:```matlabfigure;subplot(2,1,1);stem(n, xq);xlabel('时间');ylabel('幅度');title('量化信号');subplot(2,1,2);stem(n, y);xlabel('时间');ylabel('幅度');title('滤波信号');```实验结果和分析:根据以上实验步骤,可以得到正弦波信号、采样信号、量化信号和滤波信号等图像。
matlab实验报告总结1.求一份matlab的试验报告计算方法试验报告3【实验目的】检查各种数值计算方法的长期行为【内容】给定方程组x'(t)=ay(t),y'(t)=bx(t), x(0)=0, y(0)=b的解是x-y 平面上的一个椭圆,利用你已经知道的算法,取足够小的步长,计算上述方程的轨道,看看那种算法能够保持椭圆轨道不变。
(计算的时间步长要足够多)【实验设计】用一下四种方法来计算:1. Euler法2. 梯形法3. 4阶RK法4. 多步法Adams公式【实验过程】1. Euler法具体的代码如下:clear;a=2;b=1;A=[0 a; -b0];U=[];u(:,1)=[0;b];n=1000000;h=6*pi/n;fori=1:n delta(i)=((u(1,i)/a)^2+(u(2,i)/b)^2)^0.5; u(:,i+1)=u(:,i)+h*A*u(:,i);endt=1:n+1;subplot(1, 2,1);plot(1:n,delta);gridon;subplot(1,2,2);plot(u(1,:),u(2,:));gridon;max(abs(delta-ones(1,length(delta))));结果如下:2. 梯形法具体的代码如下:clear;a=2;b=1;A=[0 a; -b 0];U=[];u(:,1)=[0;b];n=300;h=6*pi/n;for i=1:n delta(i)=((u(1,i)/a)^2+(u(2,i)/b)^2)^0.5;v1=u(:,i)+h*A*u(:,i);v2=u(:,i)+h*A*(u(:,i)+v1)/2;1u(:,i+1)=u(:,i)+h*A*(u(:,i)+v2)/2;endt=1:n+1;sub plot(1,2,1);plot(1:n,delta);gridon;subplot(1,2,2);结果如下 3. 4阶RK法clear;a=2;b=1;A=[0 a; -b 0];U=[];u(:,1)=[0;b];n=70;h=6*pi/n;for i=1:n delta(i)=((u(1,i)/a)^2+(u(2,i)/b)^2)^0.5;k1=A*u(:,i); k2=A*(u(:,i)+h/2*k2); k3=A*(u(:,i)+h*k3); k4=A*(u(:,i)+h*k3); u(:,i+1)=u(:,i)+h/6*(k1+2*k2+2*k3+k4);endt=1:n+1 ;subplot(1,2,1);plot(1:n,delta);gridon;subplot(1,2,2);结果如下:4. 多步法Adams公式clear;a=2;b=1;A=[0 a; -b 0];U=[];u(:,1)=[0;b];n=200;h=6*pi/n;u(:;2)=u(u,1)+h*A*u(:,1);u(:;3)=u(u,2)+h/2*A*(3*u(:,2)-u(:,1));u(:;4)=u(u,3)+h/12*A*(23*u(:,3)-16*u(:,2)+5*u(:, 1)); delta(1)=((u(1,1)/a)^2+(u(2,1)/b^2)^0.5 delta(2)=((u(1,2)/a)^2+(u(2,2)/b^2)^0.5delta(3)=((u(1,3)/a)^2+(u(2,3)/b^2)^0.5for i=4:n delta(i)=((u(1,i)/a)^2+(u(2,i)/b)^2)^0.5;u(:,i+1)=u(:,i)+h/24*A*(55*u(:,i)-59*u(:,i-1)+37 *u(:,i-1)+37*u(:,i-2)-9*u(:,i-3));endt=1:n+1;sub plot(1,2,1);plot(1:n,delta);gridon;subplot(1,2,2);结果如下:【实验分析】通过这几种方法对比,发现最为稳定的是多步法Adams公式和4阶RK法,其次是梯形法,而欧拉法最为不稳定。
四川师范大学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 命令窗口进行简单数学运算。
2、掌握常用的操作命令和快捷键。
3、了解MATLAB 的数据类型。
4、了解MATLAB 的操作符。
[三、实验原理]MATLAB 是美国MathWorks 公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境,主要包括MATLAB 和Simulink 两大部分。
MATLAB 是matrix&laboratory 两个词的组合,意为矩阵工厂(矩阵实验室)。
[四、实验条件]实验微机、Matlab 软件。
[五、实验内容和过程]1、在命令窗口依次输入下列命令,根据执行结果分析其功能;helpmagiclookforhelp magicdoc magicwhich magic2、以自己姓名拼音来建立自己的工作目录,再讲自己的工作目录设置到Matlab 搜索路径下。
用cd 命令查询自己的工作目录3、创建变量,并计算:(1) 创建single 类型变量a=98,b=168 ,求:a+b,a-b,b×a3,b×a×a×a(2) 创建uint8 类型变量m,n,值与( 1)同,进行相同计算。
4、先求下列表达式的值,然后记录Matlab 工作空间的使用情况和相关变量[六、实验结果]1、实验结果2、实验结果3、实验结果、实验结果[七、实验结果分析、讨论]根据记录命令和结果,解释实验 3 的(1)与(2)结果为何不同:因uint8 类型变量的最大值为255,当超过最大值时结果就等于255。
[八、实验结论]通过本次实验的学习后,学会用MATLAB 命令窗口进行简单数学运算,常用的操作命令和快捷键等操作。
补充了解语句:input disp sprintf fprintf syms sym max min mod ifswitch forroundnum2str simplifyplot plot3工程数学课程实验报告(二)[一、实验名称]MATLAB 软件在行列式运算中的应用[二、实验目的]1、了解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是一款商业软件,其价格较高,对于个人用户而言可能不太容易承受。
一、实验目的:1.学会运用Matlab解决实际问题2.进一步掌握Matlab的一些基本操作3.通过范例体会Matlab的初步建模过程4学会用做动画二.实验仪器、设备或软件:电脑、MATLAB软件三.实验内容:1.已知前两年的猪肉的产量和猪肉的价格分别为:39吨,28吨,12元/公斤,17元/公斤,根据前一年的猪肉价格影响后一年猪肉产量当年猪肉产量影响当年猪肉价格的线性关系,编写程序,利用动画原理画出前十年猪肉的产量——价格的动态图形。
(参数设置为,c1=39,c2=28,c3=36,r1=12,r2=17,k=16)。
2.在地面上建有一座圆柱形水塔,水塔内部的直径为d,并且在地面处开了一个高为H的小门.现在要对水塔内部进行维修施工,施工方案要求把一根长为l(l>d)的水管运到水塔内部.请问水塔的门高H多高时,才有可能成功地把水管搬进水塔内。
四.实验记录:1.蛛网模型:实验代码:clear%c1为产量1, c2为产量2, c3为产量3, r1为%肉价1, r2为肉价2, k为K年后产量与肉价%是否稳定c1=39;c2=28;c3=36;hold offr1=12;r2=17;k=16;a1=[c1 1;c2 1];%系数矩阵b1=[r1,r2]';%列向量a2=[r1 1;r2 1];b2=[c2,c3]';a=a1\b1;b=a2\b2;%x0(1)=c1;for n=1:30y0(n)=a(1)*x0(n)+a(2); %a(1)a(2)为矩阵元素的引用,下行类似x0(n+1)=b(1)*y0(n)+b(2);x(n)=x0(n);y(n)=x0(n+1);endplot(x,y0,'-g',y,y0,'-b')hold onm=moviein(100);for n=1:kfor j=1:30t1=x0(n)+(j-1)*(x0(n+1)-x0(n))/30;t2=x0(n)+j*(x0(n+1)-x0(n))/30;if t2<t1t=t1;t1=t2;t2=t;%这样做方便画图elseendt=t1:0.01:t2;plot(t,y0(n),'.r')%划横线t1=y0(n)+(j-1)*(y0(n+1)-y0(n))/30;t2=y0(n)+j*(y0(n+1)-y0(n))/30;if t2<t1t=t1;t1=t2;t2=t;elseendt=t1:0.01:t2;plot(x(n+1),t,'.r')%划竖线endm(:,n)=getframe;endmovie(m,20)实验结果:ans =Columns 1 through 639.0000 28.0000 36.0000 30.1818 34.4132 31.3358 Columns 7 through 1233.5739 31.9462 33.1300 32.2691 32.8952 32.4398 Columns 13 through 1832.7710 32.5302 32.7053 32.5779 32.6706 32.6032 Columns 19 through 2432.6522 32.6166 32.6425 32.6236 32.6374 32.6274 Columns 25 through 3032.6346 32.6294 32.6332 32.6304 32.6324 32.6310 Column 3132.6320实验图像:2.水塔模型:实验代码:Clearfunction x=lt523(l,d,h) k1=0;a=0l=7;d=3ymax=0;k2=0;b=pi/2;h=3;while (b-a)>10^(-2)k2=k2+1;m=0;a=0;if k1==0n=ceil(b/h)-1 elsen=ceil(b/h);endfor i=1:n+1;x(i)=a+(i-1)*(b-a)/n;y(i)=l*sin(x(i))-d*tan(x(i));endfor i=1:nif y(i)>ymaxymax=y(i);a=x(i-1);else y(i)<ymaxb=x(i);endendm=m+1;k1=k1+1;h=(b-a)/5;endabx=(a+b)/2t=0:0.01:1.35y1=l*sin(t)-d*tan(t);plot(t,y1,'-b')方法:2syms h xh=8*sin(x)-2*tan(x);d1=0;d2=pi/2;d0=(d1+d2)/2;d=0.03;a=subs(h,x,d1);b=subs(h,x,d2);c=subs(h,x,d0);for n=d1:d:d2if (((c-a)/(d0-d1))*((b-c)/(d2-d0)))<0 d1=d1+d; d2=d2-d; d0=(d1+d2)/2;a=subs(h,x,d1);b=subs(h,x,d2);c=subs(h,x,d0);endendd0hold onaxis([0,pi/2,-5,5])x=0:0.05:pi/2;plot(x,8*sin(x)-2*tan(x),'-b')实验运行结果:五、实验总结:通过做此实验,让我对MATLAB有更进一步的了解,学会怎样才能正确运用MATLAB求解实际问题,了解如何利用数学模型去解释和分析社会经济问题,特别是这个典型经济问题的求解。