MATLAB报告范例

合集下载

MATLAB实验报告(打印版)

MATLAB实验报告(打印版)

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实验报告模板

《高等数学》实验报告(二)实验项目名称:多元函数积分学分组第八组组员姓名学号专业班级实验软件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实验报告实例

MATLAB实验报告实例

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 一.概述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实验报告模板

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实验报告总结

matlab实验报告总结

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实验报告(8个实验)

MATLAB实验报告(8个实验)

四川师范大学MATLAB语言实验报告1系级班年月日实验名称:Intro, Expressions, Commands姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB program development environment and to develop your first programs in this environment.2Using MATLAB2.1Starting MATLABLogon to your computer and start MATLAB by double-clicking on the icon on the desktop or by using the Start Programs menu. MATLAB Desktop window will appear on the screen.The desktop consists of several sub-windows. The most important ones are:●Command Window (on the right side of the Desktop) is used to do calculations,enter variables and run built-in and your own functions.●Workspace (on the upper left side) consists of the set of variables (arrays) createdduring the current MATLAB session and stored in memory.●Command History (on the lower left side) logs commands entered in theCommand Window. You can use this window to view previously run statements, and copy and execute selected statements.You can switch between the Launch Pad window and the Workspace window using the menu tabs under the sub-window on the upper left side. Similarly, you can switch between the Command History and Current Directory windows using the menu tabs under the sub-window on the lower left side.2.2Executing CommandsYou can type MATLAB commands at the command prompt “>>” on the Command Window.For example, you can type the formula cos(π/6)2sin(3π/8) as>>(cos(pi/6) ^ 2) * (sin(3 * pi/8))Try this command. After you finish typing, press enter. The command will be interpreted and the result will be displayed on the Command Window.Try the following by observing how the Workspace window changes:>> a = 2; (M ake note of the usage of “;”)>> b = 3;>> c = a ^ 4 ∗ b ∗ 5 + pi ^3You can see the variables a, b and c with their types and sizes on the Workspacewindow, and can see the commands on the Command History window.Spend a few minutes to practice defining array variables (i.e. vectors and matrices)usingthe square bracket (“[ ]”) and colon (“:”) operators, and zeros() and ones() functions.>> ar =[ 1 2 3 4 5 ];>> br =[ 1 2 3 ;4 5 6 ];>> cr = [1 : 3 : 15];• Set dr to 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基本操作与及用法实验报告样本

MATLAB基本操作与及用法实验报告样本

工程数学课程实验报告(一)[一、实验名称]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 实验报告Matlab 实验报告引言:Matlab(Matrix Laboratory)是一种强大的科学计算软件,它为科学家、工程师和研究人员提供了一个强大的计算环境。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

MATLAB综合性实验报告8

MATLAB综合性实验报告8

一、实验目的: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求解实际问题,了解如何利用数学模型去解释和分析社会经济问题,特别是这个典型经济问题的求解。

Matlab实验报告(1)

Matlab实验报告(1)

《Matlab语言与应用》课程实验报告*名:**班级:电信114学号:************指导老师:***二〇一三年十一月二十一日Matlab实验报告实验一一、实验问题求[12 + sin(2)×( 22 −4)]÷3^2的算术运算结果。

二、问题的分析该题主要熟悉Matlab环境下的对数学运算的熟悉,如何输入数据、建立函数输出结果。

三、上机实验结果如图四、实验的总结与体会通过本次实验,我学会了用Matlab来计算数学运算中的复杂技术。

我们也可以自己编写一个可以调用的函数,首先我们要了解Matlab语言函数的基本结构,结构如下:Function [返回变量列表]=函数名(输入变量列表)注释说明语句段,由%引导输入、返回变量格式的检测函数体语句例如:输入变量为k,返回的变量为m和s,其中s为前m项的和Function [m,s]=findsum(k)s=0;m=0;while(s<=k),m=m+1;s=s+m;end编写了函数,就可以将其存为findsum.m文件,这样就可以在Matlab环境中对不同的k值调用该函数了。

这样就可以灵活的实现我们想要的数据。

实验二一、实验问题二、问题分析输入矩阵时,空格或逗号表示间隔,分号表示换行,比如上面的矩阵A应写为A=[1,2,3;4,5,6;7,8,9]三、上机实验结果如图四、实验的总结与体会通过对本次上机实验了解到在Matlab中对矩阵的代数运算矩阵转置、矩阵的加减法运算、矩阵乘法、矩阵的左、右除、矩阵翻转、矩阵乘方运算、点运算等。

实验三一、实验要求画图,理解plot函数用法二、代码如下clear; clf;t=0:pi/20:2*pi;R=5;x=R*sin(t); y=R*cos(t);plot(x,y,'b:'), gridhold onrrr=[x;y;x+y];plot(rrr(1,:),'.','MarkerSize',10,'Color','r')plot(rrr(2,:),rrr(3,:),'o','MarkerSize',15,'Color','b'); axis([-8,20,-8,8]), % axis squarehold off三、Matlab运行结果如图实验四一、实验要求二、代码如下t=0:pi/50:4*pi;y0=exp(-t/3);y=exp(-t/3).*sin(3*t);plot(t,y,'-r',t,y0,':b',t,-y0,':b') Grid三、Matlab运行结果如图实验五一、实验要求傅里叶频谱分析二、代码及分析(1)首先生成数据,包含50Hz和120Hz频率的正弦波x >>t = 0:.001:.25;>>x = sin(2*pi*50*t) + sin(2*pi*120*t);(2)再生成噪音信号yy = x + 2*randn(size(t));plot(y(1:50))title('Noisy time domain signal')(3)对y进行快速傅里叶变换Y = fft(y,256);(4)计算功率谱Pyy = Y.*conj(Y)/256;f = 1000/256*(0:127);plot(f,Pyy(1:128))title('Power spectral density')xlabel('Frequency (Hz)')(5)只查看200Hz以下频率段plot(f(1:50),Pyy(1:50))title('Power spectral density')xlabel('Frequency (Hz)')三、上机结果如下图实验六一、实验要求FIR数字滤波器设计代码如下clear;close allf=[0,0.6,0.6,1]; m=[0,0,1,1]; % 设定预期幅频响应b=fir2(30,f,m); n=0:30; % 设计FIR 数字滤波器系数subplot(3,2,1),stem(n,b,'.')xlabel('n'); ylabel('h(n)');axis([0,30,-0.4,0.5]),line([0,30],[0,0])[h,w]=freqz(b,1,256);subplot(3,2,2),plot(w/pi,20*log10(abs(h)));gridaxis([0,1,-80,0]),xlabel('w/pi'); ylabel('幅度(dB)');二、上级结果如图实验七二、实验要求用guide实验一个简单的加减乘除计算器二、实验步骤在命令行输入guide命令,进入guide界面新建一个空白guide文件在空白文件中设置好功能模块如图模块建立好后,就要把编写好的加减乘除代码加入到各自的回调函数中,见下图两个被加数代码如下图加模块代码如下图减模块代码如下图乘模块代码如下图除模块代码如下图各模块的回调函数加完后就可以运行了,运行结果如下图总结:Matlab一个高级的距阵/阵列语言,它包含控制语句、函数、数据结构、输入和输出和面向对象编程特点。

MATLAB实验报告(8个实验)

MATLAB实验报告(8个实验)

MATLAB实验报告(8个实验)四川师范⼤学MATLAB语⾔实验报告1系级班年⽉⽇实验名称:Intro, Expressions, Commands姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB program development environment and to develop your first programs in this environment.2Using MATLAB2.1Starting MATLABLogon to your computer and start MATLAB by double-clicking on the icon on the desktop or by using the Start Programs menu. MATLAB Desktop window will appear on the screen.The desktop consists of several sub-windows. The most important ones are:●Command Window (on the right side of the Desktop) is used to do calculations,enter variables and run built-in and your own functions.●Workspace (on the upper left side) consists of the set of variables (arrays) createdduring the current MATLAB session and stored in memory.●Command History (on the lower left side) logs commands entered in theCommand Window. You can use this window to view previously run statements, and copy and execute selected statements.You can switch between the Launch Pad window and the Workspace window using the menu tabs under the sub-window on the upper left side. Similarly, you can switch between the Command History and Current Directory windows using the menu tabs under the sub-window on the lower left side.2.2Executing CommandsYou can type MATLAB commands at the command prompt “>>” on the Command Window.For example, you can type the formula cos(π/6)2sin(3π/8) as>>(cos(pi/6) ^ 2) * (sin(3 * pi/8))Try this command. After you finish typing, press enter. The command will be interpreted and the result will be displayed on the Command Window.Try the following by observing how the Workspace window changes:>> a = 2; (M ake note of the usage of “;”)>> b = 3;>> c = a ^ 4 ? b ? 5 + pi ^3You can see the variables a, b and c with their types and sizes on the Workspacewindow, and can see the commands on the Command History window.Spend a few minutes to practice defining array variables (i.e. vectors and matrices)usingthe square bracket (“[ ]”) and colon (“:”) operators, and zeros() and ones() functions.>> ar =[ 1 2 3 4 5 ];>> br =[ 1 2 3 ;4 5 6 ];>> cr = [1 : 3 : 15];Set dr to rst 3 elements of ar.dr=ar(1:3);Set er to second row of br.er=br(2,:);Set ar to [dr er]. Find the number of elements of ar.ar=[dr er]; length(ar)2.3 Getting HelpThere are several ways to get help on commands and functions in MATLAB. First ofall you can use the Help menu. You can also use the “?” button. Try to findinformation on the plot function from the help index. Also try to get information onthe same function using the help command (i.e. type help plot). Finally, experimentwith the lookfor command. This command looks for other commands related to agiven keyword.2.4 Some Useful CommandsTry the following commands and observe their results:Which : Version and location infoClear : Clears the workspaceClc : Clears the command windowwho, whos : Lists content of the workspace3 ExercisesPlease solve the following problems in MATLAB. Do not forget to keep a diary ofyour commands and their outputs.(1) De?ne the variables x y and z as 7.6, 5.5 and 8.1, respective ly, and evaluate:578.422.52??? ??-x y xz(2) Compute the slope of the line that passes through the points (1,-2) and(5,8).(3) Quiz 1.1: 5(4)1.6 Exercises: 1.1, 1.4(5)2.15 Exercises: 2.6, 2.9, 2.114Quitting MATLABTyping quit on the command window will close the program. Do not forget to send your diary file and M-file to your TA. Do not forget to delete your ?les from the hard disk of the PC you used in the lab at the end of the lab session.四川师范⼤学MATLAB语⾔实验报告2系级班年⽉⽇实验名称:Programming, Relational and Logical Expressions姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB script files (M-files), subarrays, relational and logical operators.2Script FilesScript files are collections of MATLAB statements that are stored in a file. Instead of typing commands directly in the Command Window, a series of commands may be placed into a file and the entire file may be executed by typing its name in the Command Window. Such files are called script files that are also known as M-files because they have an extension of .m. When a script file is executed, the result is the same as it would be if all of the commands had been typed directly into the Command Window. All commands and script files executed in the Command Window share a common workspace, so they can all share variables in the workspace. Note that if two script files are executed successively, the second script file can use the variables created by the first script file. In this way, script files can communicate with other script files through the data left behind in the workspace. An Edit Window is used to create new M-files or to modify existing ones. The Edit Window is a programming text editor, with the features of MATLAB language highlighted in different colors. You can create a new M-file with the File/New/M-file selection and you can open an existing M-file with the File/Open selection from the desktop menu of MATLAB. (1)Create a new working directory under the current directory and change the currentdirectory to …TA?s suggest?.3SubarraysIt is possible to select and use subsets of MATLAB arrays. To select a subset of an array, just include a list of the elements to be selected in the parentheses after the array name. MATLAB has a special function named end that is used to create array subscripts. The end function always returns the highest value taken on by a givensubscript. It is also possible to use subarrays on the left-hand side of an assignmentstatement to change only some of the values in an array. If values are assigned to asubarray, only those values are changed but if values are assigned to an array, theentire contents of the array are replaced by the new values.(1) Define the following 5 x 5 array arr1 in MATLAB.----=2274235421209518171651413215111012844563311arr(2) Write a MATLAB statement to select a subset of arr1 and return the subarraycontaining the values as shown.=22745456311arrarr11=arr1([1,5],[2 4 5]);(3) Write two MATLAB statements to select the last row and last column of arr1,separately.arr12=arr1(5,:);或arr12=arr1(end,:); arr13=arr1(:,end);或 arr13=arr1(:,5);(4) Write MATLAB statements to obtain the following array from arr1.-=2257462335432112arrarr2=arr1([1 5],:)';4 Relational and Logical OperatorsRelational and logical operators are the two types of operators that produce true/falseresults in MATLAB programs. MATLAB interprets a zero value as false and any nonzero value as true. Relational operators ( ==, =,>,>=,<,<=) are operators with two operands that produce either a true (1) or a false (0) result, depending on the values of the operands. Relational operators can be used to compare a scalar value with an array. They can also be used to compare two arrays or two strings only if they have the same size. Be careful not to confuse the equivalence relational operator ( == ) with the assignment operator ( = ). Logic operators ( &, |, xor, ~ ) are operators with one ortwo operands that yield a logical result such as 0 or 1. There are three binary logic operators: AND (& ), OR ( |), and exclusive OR ( xor ); and one unary operator: NOT ( ~ ). In the hierarchy of operations, logic operators are evaluated after allarithmetic and relational operators have been evaluated. The operator is evaluated before other logic operators.(1) Define the following 4 x 5 array arr4 in MATLAB.------=212343212343212543214arr(2) Write an expression using arr4 and a relational operator to produce the following result.=110001110011110111115arrarr5=arr4>0;(3) Write an expression using arr4 and a relational operator to produce the following result.=010000010000010000016arrarr6=arr4==1;(4) Write a MATLAB program which will generate an (n-1)x(n-1) matrix from agiven nxn matrix which will be equal to given matrix with first row and firstcolumn deleted.arr44=rand(5); arr444=arr35(2:end,2:end);(5) Generalize your program above so that the program should ask the row and column numbers to be deleted and then generate new (n-1)x(n-1) matrix.n=input('input n:');matrixn=rand(n)delrow=input('input row numbers to be deleted:');delcolumn=input('input column numbers to be deleted:');matrixn_1=matrixn([1:delrow-1 delrow+1:end], [1:delcolumn-1 delcolumn+1:end]) (6) Quiz 3.1 (P88)5 Quitting MATLABTyping quit on the command window will close the program. Do not forget to send your diary file and M-file to your TA.Do not forget to delete your files from the hard disk of the PC you used in the lab at the end of the lab session.四川师范⼤学MATLAB 语⾔实验报告3系级班年⽉⽇实验名称:Branches and Loops, Logical Arrays.姓名学号指导教师成绩 1 ObjectiveThe objective of this lab is to familiarize you with the MATLAB Branches and Loops, Logical Arrays.2 ExercisesDo not forget to add sufficient documentation and proper indentation to all programs you write.(1) Write a program that calculates follow equation with for and while loop, and writea program without loop.63263022212+++==∑= i i K% for loopk1=0;for ii=1:64k1=k1+2^(ii-1);end% while loopk2=0;n=0;while n>=0&n<64k2=k2+2^n;n=n+1;end% without loopa=0:63;b=2.^a;K3=sum(b);(2) Write a program that accepts a vector of integers as input and counts the numberof integers that are multiples of 3 in that vector. You can assume that the inputcontains only integer values. An example run of your program can be as follows:Enter a vector of integers: [ 1 3 2 8 0 5 6 ]The number of multiples of 3 is 2(3) The root mean square is a way for calculating a mean for a set of numbers. The rmsaverage of a series of numbers is given as:∑==N i i xN rmsaverage 121Write a program that will accept an arbitrary number of input values and calculatethe rmsaverage of the numbers. The program should ask the user for the numberof values to be entered. Test your program with 4 and 10 set of numbers.% The root mean square is a way for calculating a mean for a set of numbers% Initializesum_x2=0;% Get the number of points to input.n=input('Enter number of points:');% Loop to read input valuesfor ii=1:n% Read in next valuex=input('Enter value:');% Calculate square sumssum_x2=sum_x2+x^2;end% Now calculate root mean squareroot_ms=sqrt(sum_x2/n);% Tell userfprintf('The number of data points is: %d\n',n);fprintf('The root mean square of this data set is: %f\n',root_ms);(4) 3.8 exercises:3.5(5) 4.7Exercises: 4.1 4.23 Quitting MATLABTyping quit on the command window will close the program. Do not forget to sendyour M-file to your TA.Do not forget to delete your files from the hard disk of the PC you used in the lab at the end of the lab session.四川师范⼤学MATLAB语⾔实验报告4系级班年⽉⽇实验名称:MATLAB/SIMULINK package姓名学号指导教师成绩1Objective●To learn how to use MATLAB/SIMULINK package●To learn how to estimate performance parameters from time-domain data2SIMULINK BasicBasic steps(1)Click on the MATLAB button to start MATLAB.(2)Once MATLAB has started up, type simulink (SMALL LETTERS!) at theMATLAB prompt (>>) followed by a carriage return (press the return key). A SIMULINK window should appear shortly, with the following icons: Sources, Sinks, Discrete, Linear, Connections, Extras.(3)Next, go to the File menu in SIMULINK window and choose New in order tobegin building the block diagram representation of the system of interest.(4)Open one or more of the block libraries and drag the chosen blocks into the active.(5)After the blocks are placed, draw lines to connect their input and output ports bymoving the mouse over a port and drag using the left button. To make a line witha right angle in it, release the button where you want the corner, then click on theend of the line and drag to create next segment. To add a second line that runs off of an existing line click the right mouse on an existing line and drag it.(6)Save the system by selecting Save from the File menu.(7)Open the blocks by double-clicking and change some of their internal parameters.(8)Adjust some simulation parameters by selecting Parameters from the Simulationmenu. The most common parameter to change is Stop Time that defines the length of time the simulation will run.(9)Run the simulation by selecting Start from the Simulation menu. You can stop asimulation before completing by selecting Stop from the Simulation menu. (10)View the behavior of the system by attaching Scope blocks to the variables ofinterest, or by using To Workspace blocks to send data to the MATLAB workspace where you can plot the results using standard MATLAB commands.3Exercises(1)Your TA has shown you how to observe and print signals from the scope. Try thisout by printing out the input signal, which should be a -1V to 1V square wave with frequency 0.1 Hz. Note the peak-to-peak voltage difference of this signal.Note to write key blocks parameters.(2) Write a Simulink model to calculate the following differential equation,0)1(222=+--x dt dx x dt x d µInitialized 1)0(=x ,0)0(=dt dx 。

(完整word)Matlab实验报告

(完整word)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/2 3.两个函数之间的操作求和(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实验报告

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实验报告引言:Matlab是一种强大的数值计算和可视化软件,广泛应用于科学、工程和经济等领域。

本实验报告将介绍我在使用Matlab进行实验过程中的一些经验和结果。

实验一:矩阵运算在这个实验中,我使用Matlab进行了矩阵运算。

首先,我创建了一个3x3的矩阵A和一个3x1的矩阵B,并进行了矩阵相乘运算。

通过Matlab的矩阵乘法运算符*,我得到了一个3x1的结果矩阵C。

接着,我对矩阵C进行了转置操作,得到了一个1x3的矩阵D。

最后,我计算了矩阵C和矩阵D的点积,并将结果输出。

实验二:数据可视化在这个实验中,我使用Matlab进行了数据可视化。

我选择了一组实验数据,包括时间和温度两个变量。

首先,我将数据存储在一个矩阵中,并使用Matlab的plot函数将时间和温度之间的关系绘制成曲线图。

接着,我使用Matlab的xlabel、ylabel和title函数添加了横轴、纵轴和标题。

最后,我使用Matlab的legend函数添加了图例,以便更好地理解图表。

实验三:数值积分在这个实验中,我使用Matlab进行了数值积分。

我选择了一个函数f(x)进行积分计算。

首先,我使用Matlab的syms函数定义了符号变量x,并定义了函数f(x)。

接着,我使用Matlab的int函数对函数f(x)进行积分计算,并将结果输出。

为了验证结果的准确性,我还使用了Matlab的diff函数对积分结果进行了求导操作,并与原函数f(x)进行了比较。

实验四:信号处理在这个实验中,我使用Matlab进行了信号处理。

我选择了一个音频文件,并使用Matlab的audioread函数读取了该文件。

接着,我使用Matlab的fft函数对音频信号进行了傅里叶变换,并将结果绘制成频谱图。

为了进一步分析信号的特征,我还使用了Matlab的spectrogram函数绘制了信号的时频图。

通过对信号的频谱和时频图的观察,我可以更好地理解信号的频率和时域特性。

matlab实验一实验报告

matlab实验一实验报告

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

本实验旨在通过使用Matlab解决实际问题,探索其功能和应用。

一、实验目的本次实验的主要目的是熟悉Matlab的基本操作和常用函数,了解其在科学计算中的应用。

二、实验内容1. 数值计算在Matlab中,我们可以进行各种数值计算,包括基本的加减乘除运算,以及更复杂的矩阵运算和方程求解。

通过编写相应的代码,我们可以实现这些功能。

例如,我们可以使用Matlab计算两个矩阵的乘积,并输出结果。

代码如下:```matlabA = [1 2; 3 4];B = [5 6; 7 8];C = A * B;disp(C);```2. 数据可视化Matlab还提供了强大的数据可视化功能,可以将数据以图表的形式展示出来,更直观地观察数据的规律和趋势。

例如,我们可以使用Matlab绘制一个简单的折线图,来展示某个物体在不同时间下的位置变化。

代码如下:```matlabt = 0:0.1:10;x = sin(t);plot(t, x);xlabel('Time');ylabel('Position');title('Position vs. Time');```3. 图像处理Matlab还可以进行图像处理,包括图像的读取、处理和保存等操作。

我们可以通过Matlab对图像进行增强、滤波、分割等处理,以及进行图像的压缩和重建。

例如,我们可以使用Matlab读取一张图片,并对其进行灰度化处理。

代码如下:```matlabimg = imread('image.jpg');gray_img = rgb2gray(img);imshow(gray_img);```三、实验结果与分析在本次实验中,我们成功完成了数值计算、数据可视化和图像处理等任务。

matlab课程设计报告模板

matlab课程设计报告模板

matlab课程设计报告模板一、教学目标本课程的教学目标是使学生掌握MATLAB的基本功能和使用方法,能够运用MATLAB进行简单的数学计算、数据处理和图形绘制。

具体分为以下三个部分:1.知识目标:学生需要了解MATLAB的基本组成、工作环境以及常用的数学函数和工具箱。

2.技能目标:学生能够熟练使用MATLAB进行矩阵运算、数学计算、数据分析和图形绘制。

3.情感态度价值观目标:通过学习MATLAB,培养学生对科学计算和计算机辅助设计的兴趣,提高学生解决实际问题的能力。

二、教学内容根据课程目标,教学内容主要包括以下几个部分:1.MATLAB概述:介绍MATLAB的发展历程、功能特点和应用领域。

2.MATLAB基本操作:包括矩阵运算、数学计算、数据分析、图形绘制等。

3.MATLAB工具箱:介绍MATLAB常用的工具箱,如数值计算工具箱、信号处理工具箱等。

4.MATLAB实际应用案例:分析实际案例,让学生学会将MATLAB应用于实际问题的解决。

三、教学方法为了达到课程目标,我们将采用以下教学方法:1.讲授法:通过讲解MATLAB的基本概念和操作方法,使学生掌握MATLAB的基本使用技巧。

2.案例分析法:分析实际案例,让学生学会将MATLAB应用于实际问题的解决。

3.实验法:安排上机实验,让学生动手操作,巩固所学知识。

4.讨论法:学生进行小组讨论,促进学生之间的交流与合作。

四、教学资源为了支持教学内容和教学方法的实施,我们将准备以下教学资源:1.教材:《MATLAB教程》或其他类似教材。

2.参考书:提供相关的参考书籍,供学生课后自学。

3.多媒体资料:制作课件和教学视频,辅助课堂教学。

4.实验设备:提供计算机实验室,让学生进行上机实验。

五、教学评估为了全面、客观地评估学生的学习成果,我们将采取以下评估方式:1.平时表现:通过课堂参与、提问、讨论等方式,评估学生在课堂上的表现。

2.作业:布置适量的作业,评估学生对知识的掌握和应用能力。

MATLAB实验报告一二三模板

MATLAB实验报告一二三模板

2015秋2013级《MATLAB程序设计》实验报告实验一班级:软件131 姓名:付云雷学号:132872一、实验目的:1、了解MATLAB程序设计的开发环境,熟悉命令窗口、工作区窗口、历史命令等窗口的使用。

2、掌握MATLAB常用命令的使用。

3、掌握MATLAB帮助系统的使用。

4、熟悉利用MATLAB进行简单数学计算以及绘图的操作方法。

二、实验内容:1、启动MATLAB软件,熟悉MATLAB的基本工作桌面,了解各个窗口的功能与使用。

图1 MATLAB工作桌面2、MATLAB的常用命令与系统帮助:(1)系统帮助help:用来查询已知命令的用法。

例如已知inv是用来计算逆矩阵,键入help inv即可得知有关inv命令的用法。

lookfor:用来寻找未知的命令。

例如要寻找计算反矩阵的命令,可键入lookfor inverse,MATLAB即会列出所有和关键字inverse相关的指令。

找到所需的命令後,即可用help进一步找出其用法。

(2)数据显示格式:常用命令:说明format short 显示小数点后4位(缺省值)format long 显示15位format bank 显示小数点后2位format + 显示+,-,0format short e 5位科学记数法format long e 15位科学记数法format rat 最接近的有理数显示(3)命令行编辑:键盘上的各种箭头和控制键提供了命令的重调、编辑功能。

具体用法如下:↑----重调前一行(可重复使用调用更早的)↓----重调后一行→----前移一字符←----后移一字符home----前移到行首end----移动到行末esc----清除一行del----清除当前字符backspace----清除前一字符(4)MATLAB工作区常用命令:who--------显示当前工作区中所有用户变量名whos--------显示当前工作区中所有用户变量名及大小、字节数和类型disp(x) -----显示变量X的内容clear -----清除工作区中用户定义的所有变量save文件名-----保存工作区中用户定义的所有变量到指定文件中load文件名-----载入指定文件中的数据3、在命令窗口执行命令完成以下运算,观察workspace的变化,记录运算结果。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
functionUntitled_12_Callback(hObject, eventdata, handles)
membrane
shadinginterp
light('Position',[-3 -2 1]);
axisoff
functionUntitled_13_Callback(hObject, eventdata, handles)
1.通过下拉菜单或按钮组实现曲面形式、色彩图、光照模式和反射模式的选择;
2.通过三个滚动条用于选择X,Y,Z坐标以确定光源的位置;
3.通过三个滚动条和输入对话框改变视角。
4.加入按钮用于退出演示。
5.提供一些附加功能,比如坐标轴的显示,调用摄像机工具,调用打印预览功能,设置背景颜色,设置标题字体,超链接文档,消息框的调用等。
[x,y]=meshgrid([-1.5:.3:1.5],[-1:0.2:1]);
z=sqrt(4-x.^2/9-y.^2/4);
surf(x,y,z);
shadinginterp
light('Position',[-3 -2 1]);
axisoff
functionUntitled_15_Callback(hObject, eventdata, handles)
functionUntitled_36_Callback(hObject, eventdata, handles)
functionUntitled_34_Callback(hObject, eventdata, handles)
colormapeditor
functionUntitled_45_Callback(hObject, eventdata, handles)
colormap(jet)
functionUntitled_22_Callback(hObject, eventdata, handles)
colormap(hsv)
functionUntitled_23_Callback(hObject, eventdata, handles)
colormap(hot)
functionUntitled_20_Callback(hObject, eventdata, handles)
prompt={'输入方位角','输入俯仰角'};
title='视角控制';
lines=[1 1]';
answer1=inputdlg(prompt,title,lines);
a=answer1{1,1};b=answer1{2,1};
else
gui_mainfcn(gui_State, varargin{:});
end
functionlight_demo_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
(7)最后再加入一个static text,加入标题。
2:菜单设计
设计级联菜单:如图所示,详情请见程序
三、编程(代码过多,详情请见程序)
functionvarargout = light_demo(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename,...
'C:\Documents and Settings\Administrator\My Documents\My Pictures\');
functionUntitled_10_Callback(hObject, eventdata, handles)
surf(peaks);
shadinginterp
colormap(summer)
functionUntitled_27_Callback(hObject, eventdata, handles)
colormap(autumn)
functionUntitled_28_Callback(hObject, evenห้องสมุดไป่ตู้data, handles)
colormap(winter)
t=0:pi/12:3*pi;
r=abs(exp(-t/4).*sin(t));
[x,y,z]=cylinder(r,30);
surf(x,y,z);
shadinginterp
light('Position',[-3 -2 1]);
axisoff
functionUntitled_21_Callback(hObject, eventdata, handles)
functionUntitled_29_Callback(hObject, eventdata, handles)
colormap(gray)
functionUntitled_30_Callback(hObject, eventdata, handles)
colormap(bone)
functionUntitled_31_Callback(hObject, eventdata, handles)
(3)设置5个slider和5个edit text,分别控制视角和光源。
(4)设置三个按钮,分别用于设置背景颜色,设置标题字体,退出
(5)设置一个框架(panel),在框架里放入4个检查盒(checkbox),
(6)分别在axis,pop-up menu,slider,button,panel,checkbox中设置如上图所示的属性
[filename, pathname]=uiputfile({'*.jpg;*.tif;*.png;*.gif','所有图片文件';...
'*.*','所有文件'},'保存文件',...
'C:\Documents and Settings\Administrator\My Documents\My Pictures\');
functionUntitled_24_Callback(hObject, eventdata, handles)
colormap(cool)
functionUntitled_25_Callback(hObject, eventdata, handles)
colormap(spring)
functionUntitled_26_Callback(hObject, eventdata, handles)
'gui_Singleton', gui_Singleton,...
'gui_OpeningFcn', @light_demo_OpeningFcn,...
'gui_OutputFcn', @light_demo_OutputFcn,...
'gui_LayoutFcn', [] ,...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
ifnargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
colormap(copper)
functionUntitled_32_Callback(hObject, eventdata, handles)
colormap(pink)
functionUntitled_33_Callback(hObject, eventdata, handles)
colormap(lines)
functionUntitled_6_Callback(hObject, eventdata, handles)
[filename, pathname]=uiputfile({'*.jpg;*.tif;*.png;*.gif','所有图片文件';...
'*.*','所有文件'},'图片另文件',...
课程设计报告
课程名称:MATLAB程序设计及应用
设计题目:基于GUI界面的光照效果设计
姓名:
学号:
指导教师:李娟
时间:2010~2011学年第一学期
南京人口学院信息科学系
课程设计题目
基于GUI界面的光照效果设计
课程设计目的及要求:
目的:通过课程设计能熟练的应用MATLAB软件实现编程,了解程序开发过程中用到的一些基础知识,同时熟悉应用程序开发过程,熟悉GUI界面操作……要求:制作一个曲面光照效果的演示界面,能分别实现:
a=msgbox('Matlab课程设计版本1.00 10632114李岩','李岩');
b=findobj(a,'type','text');
c=findobj(a,'type','pushbutton');
set(b,'fontsize',24,'unit','normal');
set(c,'visible','off');
[x,y]=meshgrid(-4:.1:4);
相关文档
最新文档