MATLAB报告范例
- 格式:doc
- 大小:232.50 KB
- 文档页数:25
《高等数学》实验报告(二)实验项目名称:多元函数积分学分组第八组组员姓名学号专业班级实验软件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信号与系统实验报告19472[五篇范文]第一篇:MATLAB信号与系统实验报告19472信号与系统实验陈诉(5)MATLAB 综合实验项目二连续系统的频域阐发目的:周期信号输入连续系统的响应可用傅里叶级数阐发。
由于盘算历程啰嗦,最适适用MATLAB 盘算。
通过编程实现对输入信号、输出信号的频谱和时域响应的盘算,认识盘算机在系统阐发中的作用。
任务:线性连续系统的系统函数为11)(+=ωωjj H,输入信号为周期矩形波如图 1 所示,用MATLAB 阐发系统的输入频谱、输出频谱以及系统的时域响应。
-3-2-1 0 1 2 300.511.52Time(sec)图 1要领:1、确定周期信号 f(t)的频谱nF&。
基波频率Ω。
2、确定系统函数 )(Ω jn H。
3、盘算输出信号的频谱n nF jn H Y&&)(Ω=4、系统的时域响应∑∞-∞=Ω=nt jnn eY t y&)(MATLAB 盘算为y=Y_n*exp(j*w0*n“*t);要求(画出 3 幅图):1、在一幅图中画输入信号f(t)和输入信号幅度频谱|F(jω)|。
用两个子图画出。
2、画出系统函数的幅度频谱|H(jω)|。
3、在一幅图中画输出信号y(t)和输出信号幅度频谱|Y(jω)|。
用两个子图画出。
解:(1)阐发盘算:输入信号的频谱为(n)输入信号最小周期为=2,脉冲宽度,基波频率Ω=2π/ =π,所以(n)系统函数为因此输出信号的频谱为系统响应为(2)步伐:t=linspace(-3,3,300);tau_T=1/4;%n0=-20;n1=20;n=n0:n1;%盘算谐波次数20F_n=tau_T*Sa(tau_T*pi*n);f=2*(rectpuls(t+1.75,0.5)+rectpuls(t-0.25,0.5)+rectpuls(t-2.25,0.5));figure(1),subplot(2,1,1),line(t,f,”linewidth“,2);%输入信号的波形 axis([-3,3,-0.1,2.1]);grid onxlabel(”Time(sec)“,”fontsize“,8),title(”输入信号“,”fontweight“,”bold“)%设定字体巨细,文本字符的粗细text(-0.4,0.8,”f(t)“)subplot(2,1,2),stem(n,abs(F_n),”.“);%输入信号的幅度频谱xlabel(”n“,”fontsize“,8),title(”输入信号的幅度频谱“,”fontweight“,”bold“)text(-4.0,0.2,”|Fn|“)H_n=1./(i*n*pi+1);figure(2),stem(n,abs(H_n),”.“);%系统函数的幅度频谱xlabel(”n“,”fontsize“,8),title(”系统函数的幅度频谱“,”fontweight“,”bold“)text(-2.5,0.5,”|Hn|“)Y_n=H_n.*F_n;y=Y_n*exp(i*pi*n”*t);figure(3),subplot(2,1,1),line(t,y,“linewidth”,2);%输出信号的波形 axis([-3,3,0,0.5]);grid onxlabel(“Time(sec)”,“fontsize”,8),title(“输出信号”,“fontweight”,“bold”)text(-0.4,0.3,“y(t)”)subplot(2,1,2),stem(n,abs(Y_n),“.”);%输出信号的幅度频谱xlabel(“n”,“fontsize”,8),title(“输出信号的幅度频谱”,“fontweight”,“bold”)text(-4.0,0.2,“|Yn|”)(3)波形:-3-2-1 0 1 2 300.511.52Time(sec)输入信号f(t)-20-15-10-5 0 5 10 15 2000.10.20.30.4n输入信号的幅度频谱|Fn|-20-15-10-5 0 5 10 15 2000.10.20.30.40.50.60.70.80.91n系统函数的幅度频谱|Hn|-3-2-1 0 1 2 300.10.20.30.4Time(sec)输出信号y(t)-20-15-10-5 0 5 10 15 2000.10.20.30.4n输出信号的幅度频谱|Yn| 项目三连续系统的复频域阐发目的:周期信号输入连续系统的响应也可用拉氏变更阐发。
程序设计实验报告(matlab)实验一: 程序设计基础实验目的:初步掌握机器人编程语言Matlab。
实验内容:运用Matlab进行简单的程序设计。
实验方法:基于Matlab环境下的简单程序设计。
实验结果:成功掌握简单的程序设计和Matlab基本编程语法。
实验二:多项式拟合与插值实验目的:学习多项式拟合和插值的方法,并能进行相关计算。
实验内容:在Matlab环境下进行多项式拟合和插值的计算。
实验方法:结合Matlab的插值工具箱,进行相关的计算。
实验结果:深入理解多项式拟合和插值的实现原理,成功掌握Matlab的插值工具箱。
实验三:最小二乘法实验目的:了解最小二乘法的基本原理和算法,并能够通过Matlab进行计算。
实验内容:利用Matlab进行最小二乘法计算。
实验方法:基于Matlab的线性代数计算库,进行最小二乘法的计算。
实验结果:成功掌握最小二乘法的计算方法,并了解其在实际应用中的作用。
实验六:常微分方程实验目的:了解ODE的基本概念和解法,并通过Matlab进行计算。
实验内容:利用Matlab求解ODE的一阶微分方程组、变系数ODE、高阶ODE等问题。
实验方法:基于Matlab的ODE工具箱,进行ODE求解。
实验结果:深入理解ODE的基本概念和解法,掌握多种ODE求解方法,熟练掌握Matlab的ODE求解工具箱的使用方法。
总结在Matlab环境下进行程序设计实验,使我对Matlab有了更深刻的认识和了解,也使我对计算机科学在实践中的应用有了更加深入的了解。
通过这些实验的学习,我能够灵活应用Matlab进行各种计算和数值分析,同时也能够深入理解相关的数学原理和算法。
这些知识和技能对我未来的学习和工作都将有着重要的帮助。
四、实验内容与步骤:1.绘制下列曲线.(1) y=x-(x^3)/6程序输入如下:fplot('x-(x^3)/6',[-5,5],'r.');程序输出:(2) x^2+2*y^2=64程序输入如下:ezplot(' x^2+2*y^2-64',[-8,8]) 程序输出:2.设y=1/(1+exp(-t)) –pi<=t<=pi在同一图形窗口采用子图的形式绘制条形图阶梯图杆图和对数坐标图等不同图形,并对不同图形加标注说明.程序输入如下:t=-pi:pi/10:pi;y=1./(1+exp(-t));subplot(2,2,1);bar(t,y,'r');title('条形图');axis([-4,4,0,1]);subplot(2,2,2);stairs(t,y,'b');title('阶梯图');axis([-4,4,0,1]);subplot(2,2,3);stem(t,y,'g');title('杆图');axis([-4,4,0,1]);subplot(2,2,4);semilogx(t,y,'k');title('对数坐标图');axis([-4,4,0,1]);程序输出:3.绘制下列极坐标图.(1) y=5*cos(x)+4(2) y=(5*sin(x)*sin(x))/cos(x) (1)程序输入:x=0:pi/50:2*pi;y=5*cos(x)+4;polar(x,y,'-*');程序输出:(2)程序输入:x=-pi/3:pi/50:pi/3;y=(5.*sin(x).*sin(x))./cos(x);polar(x,y,'-*');程序输出:4.绘制下列三维图形(1)x=exp(-t/20).*cos(t)y=exp(-t/20).*sin(t)z=t0<=t<=2*pi(2)z=5abs(x)<=5abs(y)<=5要求应用插值着色处理(1)程序输入:t=0:pi/10:2*pi;x=exp(-t/20).*cos(t);y=exp(-t/20).*sin(t);z=t;plot3(x,y,z);title('三维图形4-1');xlabel('x');ylabel('y');zlabel('z'); grid on;程序输出:(2)程序输入:[x,y]=meshgrid(-5:0.5:5); z=0*(x-y)+5;surf(x,y,z);shading interp;title('三维图形4-2');程序输出:五、实验总结:2.绘制下列曲线,(1) y=exp(-x*x/2)/(2*pi)程序输入:fplot('exp(-x*x/2)/(2*pi)',[0,5],'r.')程序输出:(2) x=t*sin(t)y=t*cos(t)程序输入:t=0:0.1:2*pi;x=t.*sin(t);y=t.*cos(t);plot(x,y);程序输出:3.在同一坐标轴中绘制下列两条曲线并标注两曲线交叉点(1) y=2*x-0.5(2) x=sin(3*t).*cos(t)y= sin(3*t).*sin(t)0<=t<=pi程序输入:t=0:pi/100:pi;x=sin(3*t).*cos(t);y2=sin(3*t).*sin(t);y1=2*x-0.5;plot(x,y1,'m',x,y2,'g');hold onk=find(abs(y2-y1)<1e-4);x1=x(k);y3=2*x1-0.5;plot(x1,y3,'bp');程序输出:4.分别用plot和fplot函数绘制函数y=sin(1/x)的曲线,分析两曲线的差别程序输入:x=-1:pi/100:1;y=sin(1./x);subplot(2,1,1);plot(x,y,'g');subplot(2,1,2);fplot('sin(1./x)',[-1,1],'m');程序输出:两曲线的差别plot函数在取数据点时一般都是等间隔采样,fplot函数可自适应地对函数进行采样,能更好的反应函数的变化规律6.绘制曲面图形(1)x=3*u*sin(v)y=2*u*cos(v)z=4*u*u程序输入:[u,v]=meshgrid(0:pi/100:2*pi);x=3*u.*sin(v);y=2*u.*cos(v);z=4*u.*u;mesh(x,y,z);程序输出:严重觉得对细节方面很重要,,差一个点就能导致整个程序的不能运行。
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 命令窗口进行简单数学运算。
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实验报告(8个实验)四川师范大学MATLAB语言实验报告1系级班年月日实验名称:Intro, Expressions, Commands姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB program development environment and to develop your first programs in this environment.2Using MATLAB2.1Starting MATLABLogon to your computer and start MATLAB by double-clicking on the icon on the desktop or by using the Start Programs menu. MATLAB Desktop window will appear on the screen.The desktop consists of several sub-windows. The most important ones are:●Command Window (on the right side of the Desktop) is used to do calculations,enter variables and run built-in and your own functions.●Workspace (on the upper left side) consists of the set of variables (arrays) createdduring the current MATLAB session and stored in memory.●Command History (on the lower left side) logs commands entered in theCommand Window. You can use this window to view previously run statements, and copy and execute selected statements.You can switch between the Launch Pad window and the Workspace window using the menu tabs under the sub-windowon the upper left side. Similarly, you can switch between the Command History and Current Directory windows using the menu tabs under the sub-window on the lower left side.2.2Executing CommandsYou can type MATLAB commands at the command prompt “>>” on the Command Window.For example, you can type the formula cos(π/6)2sin(3π/8) as >>(cos(pi/6) ^ 2) * (sin(3 * pi/8))Try this command. After you finish typing, press enter. The command will be interpreted and the result will be displayed on the Command Window.Try the following by observing how the Workspace window changes:>> a = 2; (M ake note of the us age of “;”)>> b = 3;>> c = a ^ 4 ? b ? 5 + pi ^3You can see the variables a, b and c with their types and sizes on the Workspacewindow, and can see the commands on the Command History window.Spend a few minutes to practice defining array variables (i.e. vectors and matrices)usingthe square bracket (“[ ]”) and colon (“:”) operators, and zeros() and ones() functions.>> ar =[ 1 2 3 4 5 ];>> br =[ 1 2 3 ;4 5 6 ];>> cr = [1 : 3 : 15];Set dr to ?rst 3 elements of ar.dr=ar(1:3);Set er to second row of br.er=br(2,:);Set ar to [dr er]. Find the number of elements of ar.ar=[dr er]; length(ar)2.3 Getting HelpThere are several ways to get help on commands and functions in MATLAB. First ofall you can use the Help menu. You can also use the “?” button. Try to findinformation on the plot function from the help index. Also try to get information onthe same function using the help command (i.e. type help plot). Finally, experimentwith the lookfor command. This command looks for other commands related to agiven keyword.2.4 Some Useful CommandsTry the following commands and observe their results:Which : Version and location infoClear : Clears the workspaceClc : Clears the command windowwho, whos : Lists content of the workspace3 ExercisesPlease solve the following problems in MATLAB. Do not forget to keep a diary ofyour commands and their outputs.(1) De?ne the variables x y and z as 7.6, 5.5 and 8.1, respective ly, and evaluate:578.422.52??? ??-x y xz(2) Compute the slope of the line that passes through thepoints (1,-2) and(5,8).(3) Quiz 1.1: 5(4)1.6 Exercises: 1.1, 1.4(5)2.15 Exercises: 2.6, 2.9, 2.114Quitting MATLABTyping quit on the command window will close the program. Do not forget to send your diary file and M-file to your TA.Do not forget to delete your ?les from the hard disk of the PC you used in the lab at the end of the lab session.四川师范大学MATLAB语言实验报告2系级班年月日实验名称:Programming, Relational and Logical Expressions 姓名学号指导教师成绩1ObjectiveThe objective of this lab is to familiarize you with the MATLAB script files (M-files), subarrays, relational and logical operators.2Script FilesScript files are collections of MATLAB statements that are stored in a file. Instead of typing commands directly in the Command Window, a series of commands may be placed into a file and the entire file may be executed by typing its name in the Command Window. Such files are called script files that are also known as M-files because they have an extension of .m. When a script file is executed, the result is the same as it would be if all of the commands had been typed directly into the Command Window. All commands and script files executed in the Command Window share a common workspace, so they can all share variables in the workspace. Note that if two script files are executed successively, the second script file can use the variables created by the first script file. In this way, script files can communicate with other script files through the data left behindin the workspace. An Edit Window is used to create new M-files or to modify existing ones. The Edit Window is a programming text editor, with the features of MATLAB language highlighted in different colors. You can create a new M-file with the File/New/M-file selection and you can open an existing M-file with the File/Open selection from the desktop menu of MATLAB.(1)Create a new working directory under the current directory and change the currentdirectory to …TA?s suggest?.3SubarraysIt is possible to select and use subsets of MATLAB arrays. To select a subset of an array, just include a list of the elements to be selected in the parentheses after the array name. MATLAB has a special function named end that is used to create arraysubscripts. The end function always returns the highest value taken on by a givensubscript. It is also possible to use subarrays on the left-hand side of an assignmentstatement to change only some of the values in an array. If values are assigned to asubarray, only those values are changed but if values are assigned to an array, theentire contents of the array are replaced by the new values.(1) Define the following 5 x 5 array arr1 in MATLAB.----=2274235421209518171651413215111012844563311arr(2) Write a MATLAB statement to select a subset of arr1 and return the subarraycontaining the values as shown.=22745456311arrarr11=arr1([1,5],[2 4 5]);(3) Write two MATLAB statements to select the last row and last column of arr1,separately.arr12=arr1(5,:);或arr12=arr1(end,:); arr13=arr1(:,end);或arr13=arr1(:,5);(4) Write MATLAB statements to obtain the following array from arr1.-=2257462335432112arrarr2=arr1([1 5],:)';4 Relational and Logical OperatorsRelational and logical operators are the two types of operators that produce true/falseresults in MATLAB programs. MATLAB interprets a zero value as false and anynonzero value as true. Relational operators ( ==, =,>,>=,<,<=) are operators with twooperands that produce either a true (1) or a false (0) result, depending on the values ofthe operands. Relational operators can be used to compare a scalar value with an array.They can also be used to compare two arrays or two strings only if they have the samesize. Be careful not to confuse the equivalence relational operator ( == ) with theassignment operator ( = ). Logic operators ( &, |, xor, ~ ) are operators with one ortwo operands that yield a logical result such as 0 or 1. There are three binary logicoperators: AND (& ), OR ( |), and exclusive OR ( xor ); and oneunary operator: NOT( ~). In the hierarchy of operations, logic operators are evaluated after allarithmetic and relational operators have been evaluated. The operator is evaluatedbefore other logic operators.(1) Define the following 4 x 5 array arr4 in MATLAB.------=212343212343212543214arr(2) Write an expression using arr4 and a relational operator to produce the followingresult.=110001110011110111115arrarr5=arr4>0;(3) Write an expression using arr4 and a relational operator to produce the followingresult.=010000010000010000016arrarr6=arr4==1;(4) Write a MATLAB program which will generate an (n-1)x(n-1) matrix from agiven nxn matrix which will be equal to given matrix with first row and firstcolumn deleted.arr44=rand(5); arr444=arr35(2:end,2:end);(5) Generalize your program above so that the program should ask the row andcolumn numbers to be deleted and then generate new (n-1)x(n-1) matrix.n=input('input n:');matrixn=rand(n)delrow=input('input row numbers to be deleted:');delcolumn=input('input column numbers to be deleted:');matrixn_1=matrixn([1:delrow-1 delrow+1:end], [1:delcolumn-1 delcolumn+1:end])(6) Quiz 3.1 (P88)5 Quitting MATLABTyping quit on the command window will close the program. Do not forget to sendyour diary file and M-file to your TA.Do not forget to delete your files from the hard disk of the PC you used in the lab atthe end of the lab session.四川师范大学MATLAB 语言实验报告3系级班年月日实验名称:Branches and Loops, Logical Arrays.姓名学号指导教师成绩 1 ObjectiveThe objective of this lab is to familiarize you with the MATLAB Branches and Loops,Logical Arrays.2 ExercisesDo not forget to add sufficient documentation and proper indentation to all programsyou write.(1) Write a program that calculates follow equation with for and while loop, and writea program without loop.63263022212+++==∑= i i K% for loopk1=0;for ii=1:64k1=k1+2^(ii-1);end% while loopk2=0;n=0;while n>=0&n<64k2=k2+2^n;n=n+1;end% without loopa=0:63;b=2.^a;K3=sum(b);(2) Write a program that accepts a vector of integers as input and counts the numberof integers that are multiples of 3 in that vector. You can assume that the inputcontains only integer values. An example run of your program can be as follows:Enter a vector of integers: [ 1 3 2 8 0 5 6 ]The number of multiples of 3 is 2(3) The root mean square is a way for calculating a mean fora set of numbers. The rmsaverage of a series of numbers is given as:∑==N i i xN rmsaverage 121Write a program that will accept an arbitrary number of input values and calculatethe rmsaverage of the numbers. The program should ask the user for the numberof values to be entered. Test your program with 4 and 10 set of numbers.% The root mean square is a way for calculating a mean for a set of numbers% Initializesum_x2=0;% Get the number of points to input.n=input('Enter number of points:');% Loop to read input valuesfor ii=1:n% Read in next valuex=input('Enter value:');% Calculate square sumssum_x2=sum_x2+x^2;end% Now calculate root mean squareroot_ms=sqrt(sum_x2/n);% Tell userfprintf('The number of data points is: %d\n',n);fprintf('The root mean square of this data set is: %f\n',root_ms);(4) 3.8 exercises:3.5(5) 4.7Exercises: 4.1 4.23 Quitting MATLABTyping quit on the command window will close the program. Do not forget to sendyour M-file to your TA.Do not forget to delete your files from the hard disk of the PC you used in the lab at the end of the lab session.四川师范大学MATLAB语言实验报告4系级班年月日实验名称:MATLAB/SIMULINK package姓名学号指导教师成绩1Objective●To learn how to use MATLAB/SIMULINK package●To learn how to estimate performance parameters from time-domain data2SIMULINK BasicBasic steps(1)Click on the MATLAB button to start MATLAB.(2)Once MATLAB has started up, type simulink (SMALL LETTERS!) at theMATLAB prompt (>>) followed by a carriage return (press the return key). A SIMULINK window should appear shortly, with the following icons: Sources, Sinks, Discrete, Linear, Connections, Extras.(3)Next, go to the File menu in SIMULINK window and choose New in order tobegin building the block diagram representation of the system of interest.(4)Open one or more of the block libraries and drag the chosen blocks into the active.(5)After the blocks are placed, draw lines to connect their input and output ports bymoving the mouse over a port and drag using the left button. To make a line witha right angle in it, release the button where you want thecorner, then click on theend of the line and drag to create next segment. To add a second line that runs off of an existing line click the right mouse on an existing line and drag it.(6)Save the system by selecting Save from the File menu.(7)Open the blocks by double-clicking and change some of their internal parameters.(8)Adjust some simulation parameters by selecting Parameters from the Simulationmenu. The most common parameter to change is Stop Time that defines the length of time the simulation will run.(9)Run the simulation by selecting Start from the Simulation menu. You can stop asimulation before completing by selecting Stop from the Simulation menu. (10)View the behavior of the system by attaching Scope blocks to the variables ofinterest, or by using To Workspace blocks to send data to the MATLAB workspace where you can plot the results using standard MATLAB commands.3Exercises(1)Your TA has shown you how to observe and print signals from the scope. Try thisout by printing out the input signal, which should be a -1V to 1V square wave with frequency 0.1 Hz. Note the peak-to-peak voltage difference of this signal.Note to write key blocks parameters.(2) Write a Simulink model to calculate the following differential equation,0)1(222=+--x dt dx x dt x d μInitialized 1)0(=x ,0)0(=dt dx 。
一、实验目的: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操作环境.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命令窗口进行简单数学运算。
学生实验报告开课学院及实验室: 机电学院2012年12月21日学院机电学院年级、专业、班姓名学号实验课程名称MATLAB程序设计成绩实验项目名称实验4: 数据和函数的可视化指导老师一、实验目的1、掌握MATLAB绘图的基本步骤和相关指令调用的先后顺序。
2、掌握MATLAB绘图指令的调用方法。
二、实验内容数学函数从形式上可以分为离散函数和连续函数。
MATLAB对这两种函数数据的可视化都提供了相应的指令。
仔细阅读教材【例5.1-1】的实现代码, 运行并保存结果;并改用stem函数, 画出【例5.1-1】的序列图。
仔细阅读教材【例5.1-2】的实现代码, 运行并保存结果;并分别使用描点和连折线方式, 画出连续函数y=xcosx的近似图形(采样点数自定, 要求画出的图尽量接近原连续函数的图)。
仔细阅读【例5.2-2】的实现代码, 理解plot指令画多条曲线的运用方法, 运行并保存结果;并使用plot函数和legend函数, 在同一个图形窗口上画出y=sint和y=sin(2t)在[0,2pi]区间上的图形, 并标出图例。
仔细阅读【例5.2-4】的实现代码, 理解图形标识选项的运用方法, 运行并保存结果;并修改代码, 把“sin(t)”字体改为正体, 大小改为20, “极大值”改为宋体。
阅读【例5.2-6】, 理解使用hold on指令画多幅图的方法, 运行并保存结果。
阅读【例5.2-8】, 理解使用subplot函数画多个子图的方法, 运行并保存结果。
(1)综合实验: 阅读以下关于通过绘制二阶系统阶跃响应综合演示图形标识的示例, 理解示例中所有图形标识指令的作用, 掌握各个图形标识指令的运用方法, 并在原指令上改动以实现以下功能:(2)把横坐标范围改为0至5pi, 纵坐标范围改为0至2;(3)把图中的横轴的刻度改为从0开始到4pi, 中间各点间隔为pi/2;纵轴刻度改为从0开始到1.5, 中间各点间隔为0.3;(4)把图中的α改为σ。
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进行了矩阵运算。
首先,我创建了一个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软件二、实验目的1.熟悉MA TLAB的命令窗口。
2、掌握MATLAB的一些基本操作, 能够进行一般的数值计算。
3.实现语句的重调和修改。
三、实验内容与步骤1.启动MA TLAB2.观察MA TLAB窗口的各个组成部分(1)了解菜单栏各窗口项的功能, 用鼠标打开MA TLAB的各个菜单, 在状态栏里显示当前鼠标所指的菜单项的含义。
(2)用鼠标指向常用工具栏的每个工具按钮, 了解各工具按钮的含义。
3.命令窗口的打开和关闭(1)查看菜单窗口中有哪些菜单命令。
(2)在命令窗口中输入命令a=3;b=4;y=a*b+a/b, 然后回车, 查看命令显示结果。
>> a=3;b=4;y=a*b+a/b,y =12.7500(3)利用MA TLAB中编辑命令时常用的按键功能, 调用上一个语句, 对它进行修改(如把分号改成逗号, 看运行结果), 并把运行结果复制到word中保存。
>> a=3,b=4,y=a*b+a/b,a =3b =4y =12.7500(4)关闭命令窗口。
(5)打开命令窗口。
4.使用MA TLAB帮助熟悉MATLAB的帮助系统, 通过帮助系统了解有关内容。
5、在命令窗口中输入demo, 将出现MA TLAB的演示窗, 通过演示窗, 对MATLAB的功能进行一次浏览。
四、练习1.计算y=x^3+(x-0.98)^2/(x+1.25)^3-5*(x+1/x), x=2, x=3时的值。
>> x=2;y=x^3+(x-0.98)^2/(x+1.25)^3-5*(x+1/x)y =-4.4697>> x=3;y=x^3+(x-0.98)^2/(x+1.25)^3-5*(x+1/x)y =10.38652.计算cos(pi/3)-sqrt(9-sqrt(2))>> cos(pi/3)-sqrt(9-sqrt(2))ans =-2.25423.已知: a=3,A=4,b=a^2,B=b^2-1,c=a+A-2*B,C=a+B+2*c, 求: C>> a=3;A=4;b=a^2;B=b^2-1;c=a+A-2*B;C=a+B+2*cC =-2234.复数z1=1+3*i,z2=1+2*i,z3=2*exp((pi/6)*i),求z=(z1*z2)/z3>> z1=1+3*i;z2=1+2*i;z3=2*exp((pi/6)*i);z=(z1*z2)/z3z =-0.9151 + 3.4151i实验二矩阵和数组的操作一、实验环境计算机MATLAB软件二、实验目的1.掌握矩阵和数组的一般操作, 包括创建、保存、修改和调用等。
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 R2020a 版本,运行在 Windows 10 操作系统上。
计算机配置为:Intel Core i5 处理器,8GB 内存。
三、实验内容及步骤1、矩阵运算创建一个 3×3 的矩阵 A,元素分别为 1 到 9。
创建一个 3×3 的零矩阵 B。
计算 A+B 和 A×B 的结果。
在 MATLAB 中,我们可以使用以下代码实现:```matlabA = 1 2 3; 4 5 6; 7 8 9;B = zeros(3);C = A + B;D = A B;disp(C);disp(D);```2、数据类型转换定义一个整数变量 x 为 5。
将 x 转换为双精度浮点数。
将 x 转换为字符串类型。
代码如下:```matlabx = 5;y = double(x);z = num2str(x);disp(y);disp(z);```3、函数调用定义一个函数 fun,输入参数为 x,返回值为 x 的平方。
调用函数 fun,计算 3 的平方。
函数定义及调用代码:```matlabfunction y = fun(x)y = x^2;endresult = fun(3);disp(result);```4、图形绘制绘制函数 y = sin(x)在区间0, 2π上的图像。
使用以下代码实现:```matlabx = 0:001:2pi;y = sin(x);plot(x, y);```四、实验结果1、矩阵运算A+B 的结果为:```matlab1 2 34 5 67 8 9```A×B 的结果为:```matlab0 0 00 0 00 0 0```2、数据类型转换将整数 5 转换为双精度浮点数,结果为 50000。
课程设计报告课程名称:MATLAB程序设计及应用设计题目:基于GUI界面的光照效果设计姓名:学号:指导教师:李娟时间:2010 ~ 2011 学年第一学期南京人口学院信息科学系课程设计详细内容:一、方案设计1.课程设计目标用GUIDE编写一个简易的光照控制图形化界面2.功能描述光照控制界面能实现的功能绘出不同类型的三维图,能够从本地磁盘中打开图片文件选择各种色图或自定义色图选择不同的光照模式选择不能的反射模式控制视角控制光源位置设置背景颜色,标题字体附加一些辅助功能提供文档超链接3.性能描述(1)编程硬件环境CPU:Intel?Core(TM) 2 Duo CPU内存 : ;硬盘:500G;(2)编程软件环境系统:WindowsXP professionalMatlab版本:2010a二、GUI界面设计总体样式为:1:界面设计(1)建立一个坐标轴,用于显示图形(2)设置4个pop-up menu,用于设置光照效果(3)设置5个slider和5个edit text,分别控制视角和光源。
(4)设置三个按钮,分别用于设置背景颜色,设置标题字体,退出(5)设置一个框架(panel),在框架里放入4个检查盒(checkbox),(6)分别在axis,pop-up menu,slider,button,panel,checkbox中设置如上图所示的属性(7)最后再加入一个static text,加入标题。
2:菜单设计设计级联菜单:如图所示,详情请见程序。
. .. . 课程设计报告
课程名称:MATLAB程序设计及应用
设计题目:基于GUI界面的光照效果设计
:
学号:
指导教师:娟
时间:2010 ~2011 学年第一学期
人口学院信息科学系
➢系统:WindowsXP professional
➢Matlab版本:2010a
二、GUI界面设计
总体样式为:
1:界面设计
(1)建立一个坐标轴,用于显示图形
(2)设置4个pop-up menu,用于设置光照效果
(3)设置5个slider和5个edit text,分别控制视角和光源。
(4)设置三个按钮,分别用于设置背景颜色,设置标题字体,退出
(5)设置一个框架(panel),在框架里放入4个检查盒(checkbox),
(6)分别在axis,pop-up menu,slider,button,panel,checkbox中设置如上
图所示的属性
(7)最后再加入一个static text,加入标题。
2:菜单设计
设计级联菜单:如图所示,详情请见程序
三、编程(代码过多,详情请见程序)
function varargout = light_demo(varargin)
gui_Singleton = 1;。