收藏 分销(赏)

matlab实验指导答案详解.doc

上传人:快乐****生活 文档编号:10820840 上传时间:2025-06-18 格式:DOC 页数:23 大小:1.17MB 下载积分:10 金币
下载 相关 举报
matlab实验指导答案详解.doc_第1页
第1页 / 共23页
matlab实验指导答案详解.doc_第2页
第2页 / 共23页


点击查看更多>>
资源描述
<p>实验一 &nbsp;MATLAB工作环境熟悉及简单命令的执行 一、实验目的:熟悉MATLAB的工作环境,学会使用MATLAB进行一些简单的运算。 二、实验内容:MATLAB的启动和退出,熟悉MATLAB的桌面(Desktop),包括菜单(Menu)、工具条 (Toolbar)、命令窗口(Command Window)、历史命令窗口、工作空间(Workspace)等;完成一些基本的矩阵操作;学习使用在线帮助系统。 三、实验步骤: 1、启动MATLAB,熟悉MATLAB的桌面。 2、在命令窗口执行命令完成以下运算,观察workspace的变化,记录运算结果。 (1)(365-52´2-70)¸3 &gt;&gt;(365-52*2-70)/3 ans = 63.6667 (2)&gt;&gt;area=pi*2.5^2 area = 19.6350 (3)已知x=3,y=4,在MATLAB中求z: &gt;&gt;x=3 &gt;&gt;y=4 &gt;&gt;z = x ^2 * y ^3 / (x - y) ^2 z = 576 (4)将下面的矩阵赋值给变量m1,在workspace中察看m1在内存中占用的字节数。 m1= 执行以下命令 &gt;&gt;m1 =[16 &nbsp;2 &nbsp;3 &nbsp;13 ; 5 &nbsp;11 &nbsp;10 &nbsp;8 ; 9 &nbsp;7 &nbsp;6 &nbsp;12 ; 4 &nbsp;14 &nbsp;15 &nbsp;1 ] &gt;&gt;m1( 2 , 3 ) ans = 10 &gt;&gt;m1( 11 ) ans = 6 &gt;&gt;m1( : , 3 ) ans =3 &nbsp; &nbsp;10 &nbsp; &nbsp; 6 &nbsp; &nbsp;15 &gt;&gt;m1( 2 : 3 , 1 : 3 ) ans =5 &nbsp; &nbsp;11 &nbsp; &nbsp;10 &nbsp; &nbsp; 9 &nbsp; &nbsp; 7 &nbsp; &nbsp; 6 &gt;&gt;m1( 1 ,4 ) + m1( 2 ,3 ) + m1( 3 ,2 ) + m1( 4 ,1) ans = 34 (5)执行命令&gt;&gt;help abs 查看函数abs的用法及用途,计算abs( 3 + 4i ) (6)执行命令 &gt;&gt;x=0:0.1:6*pi; &gt;&gt;y=5*sin(x); &gt;&gt;plot(x,y) (6)运行MATLAB的演示程序,&gt;&gt;demo,以便对MATLAB有一个总体了解。 四、思考题 1、以下变量名是否合法?为什么? (1)x2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;合法 (2)3col &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;不合法,首字符是数字 (3)_row &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 不合法,首字符必须是字母 (4)for &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 不合法,for为MATLAB的保留关键字 2、求以下变量的值,并在MATLAB中验证。 (1)a = 1 : 2 : 5 ; a = 1 &nbsp; &nbsp; 3 &nbsp; &nbsp; 5 (2)b = [ a&#39; &nbsp;a&#39; &nbsp;a&#39; ] ; b = &nbsp;1 &nbsp; &nbsp; 1 &nbsp; &nbsp; 1 &nbsp; &nbsp; 3 &nbsp; &nbsp; 3 &nbsp; &nbsp; 3 &nbsp; &nbsp; 5 &nbsp; &nbsp; 5 &nbsp; &nbsp; 5 (3)c = a + b ( 2 , : ) c =4 &nbsp; &nbsp; 6 &nbsp; &nbsp; 8 实验二 &nbsp;MATLAB语言矩阵运算 一、实验目的:掌握基本的矩阵运算及常用的函数。 二、实验内容: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1、下列运算是否合法,为什么?如合法,结果是多少? (1) result1 = a&#39; (2) result2 = a * b 不合法,两矩阵的内阶不相等。 (3) result3 = a + b (4) result4 = b * d (5) result5 = [b ; c&#39; ] * d (6) result6 = a . * b (7) result7 = a . / b (8) result8 = a . * c 不合法,两矩阵的维数不相等,点乘相求两矩阵的维数相同。 (9) result9 = a . \ b (10) result10 = a . ^2 (11) result11 = a ^2 不合法,a矩阵不是方阵,方阵才能取平方。 (12) result12 = 2 . ^ a 以上运算的关键不是结果是多少,而是结果怎么得来的,比如result5 = [b ; c&#39; ] * d,要学会将其分解后去理解,可在命令窗口输入以下语句: &gt;&gt;c&#39; &gt;&gt;t=[b;c&#39;] &gt;&gt;r5=t * d 2、用MATLAB求下面的的方程组。 (1) A=[7,2,1,-2;9,15,3,-2;-2,-2,11,5;1,3,2,13] b=[4;7;-1;0] x=A\b x = 0.4979 &nbsp; 0.1445 &nbsp; 0.0629 &nbsp; -0.0813 (2) &nbsp; &nbsp; &nbsp; &nbsp;A=[1,1,1,0;1,2,1,-1;2,-1,0,-3;3,3,5,-6] &nbsp; &nbsp; &nbsp; &nbsp;b=[1;8;3;5] xyzw=inv(A)*b xyzw= 1.0000 &nbsp; &nbsp; 5.0000 &nbsp; &nbsp;-5.0000 &nbsp; &nbsp;-2.0000 3、已知 A=[7,2,1,-2;9,15,3,-2;-2,-2,11,5;1,3,2,13] (1)求矩阵A的秩(rank) &gt;&gt;rank(A) (2)求矩阵A的行列式(determinant) &gt;&gt;det(A) (3)求矩阵A的逆(inverse) &gt;&gt;inv(A) (4)求矩阵A的特征值及特征向量(eigenvalue and eigenvector) &gt;&gt;[v,d]=eig(A) 该题目要求大家学会使用MATLAT的帮助系统,一是知道函数名,怎样查函数用法,二是不知道函数名,怎样查函数名及其用法。 4、关系运算与逻辑运算 &nbsp; 已知a=20,b=-2,c=0,d=1 (1) r1 = a &gt; b (2) r2 = a &gt; b &nbsp;&amp; &nbsp;c &gt; d (3) r3 = a == b* (-10) (4) r4 = ~b | c r1 = 1,r2 = 0,r3 = 1,r4 = 0 三、思考题 ,求y=?(用format &nbsp;long &nbsp;g查看y的值) 方法一: n=-10:1:10 format long g x=2 .^n y=sum(x) 方法二: y=0; for t=-10:10 &nbsp; y=y+2^t; end y 方法三 y=0; &nbsp; t=-10 while t&lt;=10 &nbsp;y=y+2^t; &nbsp;t=t+1; end y 实验三 &nbsp;选择结构程序设计及调试 一、实验目的:掌握利用if、switch语句编写选择结构程序,学会MATLAB程序编辑、运行及调试方法。 二、实验内容: 1、求分段函数的值。 用if语句实现,算出下列表中x对应的y值。 X -5 0 2 5 8 y 14 6 0 19 55 clc clear x=-5 &nbsp;% x=input(&#39;请输入x的值&#39;) if x&lt;0 y=&quot;x^2+x-6;&quot; elseif=&quot;&quot; x=&quot;&quot;&gt;=0&amp;x&lt;5 &nbsp; &nbsp;y=x^2-5*x+6; else &nbsp; &nbsp;y=x^2-x-1; end y 2、分别用if和swith语句实现,将百分制成绩转换为成绩等级A、B、C、D、E。其中[90~100]分为A,[80~90)分为B,[70~80)分为C,[60~70)分为D,60分以下为E。对超出百分制范围的成绩,给出错误提示信息。 clc clear s=input(&#39;请输入百分制成绩:&#39;); if s&lt;0|s&gt;100 &nbsp; &nbsp;g=&#39;ERROR&#39;; elseif s&gt;=90&amp;s&lt;=100 g=&quot;A&quot; elseif=&quot;&quot; s=&quot;&quot;&gt;=80&amp;s&lt;90 g=&quot;B&quot; elseif=&quot;&quot; s=&quot;&quot;&gt;=70&amp;s&lt;80 g=&quot;C&quot; elseif=&quot;&quot; s=&quot;&quot;&gt;=60&amp;s&lt;70 1=&quot;&quot; 6=&quot;&quot; 7=&quot;&quot; 8=&quot;&quot; 9=&quot;&quot; g=&quot;&quot; else=&quot;&quot; end=&quot;&quot; clc=&quot;&quot; clear=&quot;&quot; s=&quot;=100&quot; switch=&quot;&quot; case=&quot;&quot; otherwise=&quot;&quot; if=&quot;&quot; x1=&quot;10+floor(90*rand(1))&quot; x2=&quot;10+floor(90*rand(1))&quot; p=&quot;&quot; y=&quot;&quot; n=&quot;&quot; classic=&quot;&quot; problem=&quot;&quot; from=&quot;&quot; number=&quot;&quot; theory.=&quot;&quot; a=&quot;n;&quot; while=&quot;&quot;&gt;1 &nbsp; &nbsp; &nbsp; &nbsp;if rem(n,2)==0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n=n/2; &nbsp; &nbsp; &nbsp; &nbsp;else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n=3*n+1; &nbsp; &nbsp; &nbsp; &nbsp;end &nbsp; &nbsp; &nbsp; &nbsp;a=[a,n]; &nbsp; &nbsp;end &nbsp; &nbsp;a 2、根据,当n分别取100、1000、10000时,求x的值分别是多少? clc clear y=0; n=100 for k=1:n &nbsp; y=y+1/k^2; end x=sqrt(6*y) 3、编程求满足的最小m值。 以下是三种方法及结果验证方法。 clc clear sum_x=0; n=0; while &nbsp;sum_x&lt;=1e4 &nbsp; &nbsp;n=n+1; &nbsp; &nbsp;x=2^n; &nbsp; &nbsp;sum_x=sum_x+x; end re1=n sum_x=0; n=1; while &nbsp;sum_x&lt;=1e4 1=&quot;&quot; x=&quot;2^n;&quot; sum_x=&quot;&quot; n=&quot;1;&quot; end=&quot;&quot; re2=&quot;n-1&quot; while=&quot;&quot; if=&quot;&quot;&gt;1e4 &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; &nbsp;end &nbsp; &nbsp;n=n+1; end re3=n echo on sum(2.^[1:12]) sum(2.^[1:13]) echo off 三、思考题 已知y和t的函数关系:求下面表格中与t对应的y值 t 0.2 0.4 0.6 0.8 1.0 y clc clear y=1 t=1; f=1; for n=1:20 &nbsp; &nbsp;f=f*n; &nbsp; &nbsp;y=y+t^n/f end y 实验五 &nbsp;函数的编写及调试 一、实验目的:掌握MATLAB函数的编写及调试方法。 二、实验内容: 1、编写一个函数,计算下面函数的值,给出x的值,调用该函数后,返回y的值。 function [y]=myfun1(x) 选择一些数据测试你编写的函数。 function [y]=myfun1(x) if x&lt;=0 &nbsp; &nbsp;y=sin(x); elseif x&lt;=3 y=&quot;-x+6;&quot; else=&quot;&quot; end=&quot;&quot; function=&quot;&quot; root=&quot;&quot; mean=&quot;&quot; x=&quot;rand(1,200),得到的x为200个(0,1)之间均匀分布的随机数。&quot; m_x=&quot;mean(x);&quot; max_x=&quot;x(1);&quot; min_x=&quot;x(1);&quot; rms_x=&quot;sqrt(sum(x.^2)/length(x));&quot; n=&quot;length(x);&quot; sum_x=&quot;sum_x+x(k);&quot; sum_x2=&quot;sum_x2+x(k)^2;&quot; for=&quot;&quot; k=&quot;1:N&quot; if=&quot;&quot;&gt;max_x &nbsp; &nbsp; &nbsp; &nbsp;max_x=x(k); &nbsp; &nbsp;end &nbsp; &nbsp;if x(k)</p><min_x min_x="x(k);" end="" m_x="sum_x/N;" rms_x="sqrt(sum_x2/N);" function="">&gt;v=myvander([2 &nbsp;3 &nbsp;4 &nbsp;5]) 得v= 生成一些数据测试你写的函数。 function [v]=myvander(x) N=length(x); for k=1:N &nbsp; &nbsp;v(k,:)=x.^(k-1); end 三、思考题 编写程序,用如下迭代公式求,a的值分别为:3,17,113。迭代的终止条件为,迭代初值,迭代次数不超过100次。分别对迭代结果和准确值进行比较,并统计迭代次数。 clc clear a=input(&#39;请输入a=&#39;); x0=1; for n=1:100 &nbsp; &nbsp;x1=x0/2+a/(2*x0); &nbsp; &nbsp;if(abs(x1-x0)&lt;=1e-5) &nbsp; &nbsp; &nbsp; &nbsp;break &nbsp; &nbsp;end &nbsp; &nbsp;x0=x1; end disp(&#39;sqrt(a)数值解为:&#39;) x1 disp(&#39;迭代次数:&#39;) n disp(&#39;sqrt(a)的准确解为:&#39;) sqrt(a) 请输入a=3 sqrt(a)数值解为: x1 = &nbsp; &nbsp;1.7321 迭代次数:5 sqrt(a)的准确解为: ans = &nbsp; &nbsp;1.7321 实验六 MATLAB的绘图 1、在同一坐标系下绘制下面三个函数在tÎ[0,4p]的图象。 t=0:1e-2:4*pi; y1=t; y2=sqrt(t); y3=4*pi*exp(-0.1*t).*sin(t); plot(t,y1,&#39;r&#39;,t,y2,&#39;g&#39;,t,y3,&#39;b&#39;); grid xlabel(&#39;t / s&#39;) ylabel(&#39;y1 &nbsp;y2 &nbsp;y3&#39;) legend(&#39;t&#39;,&#39;sqrt(t)&#39;,&#39;4*pi*exp(-0.1*t).*sin(t)&#39;); 2、编写程序,选择合适的步距,绘制下面函数在区间[-6,6]中的图象。 x=-6:0.1:6; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;% 设定自变量x的取值范围 leng=length(x); &nbsp; &nbsp; &nbsp;% 计算向量x的长度 for m=1:leng &nbsp; &nbsp; &nbsp; &nbsp; % 计算函数值 &nbsp;y(m)=myfun1(x(m)); end plot(x,y),grid &nbsp; &nbsp; &nbsp; &nbsp;%绘制函数曲线 xlabel(&#39;x&#39;),ylabel(&#39;y&#39;) 3、用compass函数画下面相量图 ua = 1 ; ub = cos(-2*pi/3)+sin(-2*pi/3)*i ; uc=cos(2*pi/3)+sin(2*pi/3)*i; compass([ua,ub,uc,ua-ub,ub-uc,uc-ua]) 4、三维空间曲线绘制 z=0:0.1:4*pi; x=cos(z); y=sin(z); plot3(x,y,z) 5、用mesh或surf函数,绘制下面方程所表示的三维空间曲面,x和y的取值范围设为[-3,3]。 [x,y]=meshgrid(-3:0.5:3) z=-x.*x/10+y.*y/10; mesh(x,y,z); figure surfc(x,y,z); 附:画抛物面 theta=linspace(0,2*pi,60) R=linspace(0,5,20); X1=R&#39;*cos(theta); Y1=R&#39;*sin(theta); Z1=X1.*X1/10+Y1.*Y1/10; mesh(X1,Y1,Z1) axis square 三、思考题 用对分法求解方程在[0,1]内的解,并验证,在程序中统计出对分次数。 提示:先将原方程转化成的形式。 对分法的基本思想是:一个一元方程f(x)=0,若f(x1)*f(x2)&lt;0,则在[x1,x2]区间内有实数解。取该区间的中点xm=(x1+x2)/2,判定f(x1)和f(x2)二者中哪一个与f(xm)异号,若f(x1)*f(xm)&lt;0,则解存在的区间缩小为[x1,xm],否则解存在的区间缩小为[xm,x2]。重复这样的步骤,直到区间的长度小于一个可以接受的小数(比如1e-10),则认为中点即是原方程的解。 clc=&quot;&quot; clear=&quot;&quot; x1=&quot;0;x2=1;&quot; len=&quot;&quot; n=&quot;0;&quot; while=&quot;&quot;&gt;1e-10 &nbsp; &nbsp;y1=2*exp(-x1)-sin(x1); &nbsp; &nbsp;y2=2*exp(-x2)-sin(x2); &nbsp; &nbsp;xm=(x1+x2)/2; &nbsp; &nbsp;ym=2*exp(-xm)-sin(xm); &nbsp; &nbsp;if y1*ym&lt;0 &nbsp; &nbsp; &nbsp; &nbsp;x2=xm; &nbsp; &nbsp;elseif &nbsp;y2*ym&lt;0 &nbsp; &nbsp; &nbsp; &nbsp;x1=xm; &nbsp; &nbsp;end &nbsp; &nbsp;len=x2-x1; &nbsp; &nbsp;n=n+1; end format long xm,ym,n 实验七 MATLAB数值运算 一、实验目的:掌握MATLAB常用的数值运算函数。 二、实验内容: 1、求代数方程的5个根,并将其用星号(*)标记在复平面图上。(用roots和plot函数)。 p=[3 4 7 2 9 12]; r=roots(p) plot(r,&#39;*&#39;); grid xlabel(&#39;Real Axis&#39;) ylabel(&#39;Imag Axis&#39;) r = &nbsp;-0.8612 + 1.4377i &nbsp;-0.8612 - 1.4377i &nbsp; 0.6737 + 1.0159i &nbsp; 0.6737 - 1.0159i &nbsp;-0.9583 &nbsp; 2、求代数方程的5个根,并将其用星号(*)标记在复平面图上。(用roots和plot函数)。 p=[1 0 0 0 0 -1]; r=roots(p) plot(r,&#39;*&#39;); axis equal grid 3、求下面函数在[0.5,4]区间内的过零点。(用fzero函) fplot(&#39;x^3-2*x^2*sin(x)+5*x*cos(x)+1/x&#39;,[0.5,4]) x1=fzero(&#39;x^3-2*x^2*sin(x)+5*x*cos(x)+1/x&#39;,[0.5,2]) x2=fzero(&#39;x^3-2*x^2*sin(x)+5*x*cos(x)+1/x&#39;,[2,4]) x1 = 1.5117 x2 = 2.6095 4、 已知R=50欧姆,U=4V,二极管D正向电流与电压的关系为: 其中: Ud为二极管正向电压 Is为反向饱合电流,取10-12A K为玻尔茨曼常数,1.38*10-23 T为绝对温度,取300开尔文(27摄氏度) q为电子电荷1.6*10-19C 求此电路中的电流Id和二极管正向电压Ud(要求用fsolve函数求解) R=50;U=4;Is=1e-12;K=1.38e-23;T=300;q=1.6e-19; %Ud+Id*R-U=0; %Id-Is*exp(Ud*q/(K*T)-1)=0; Ud=0:0.01:0.7; Id=Is*exp(Ud*q/(K*T)-1); Ud1=0:0.01:4; Id1=(U-Ud1)/R &nbsp; plot(Ud,1000*Id,&#39;r&#39;) hold on plot(Ud1,1000*Id1,&#39;b&#39;) grid hold off legend(&#39;二极管伏安特性&#39;,&#39;负载线&#39;) x=fsolve(@UdId,[1 &nbsp;0.05]) function f=UdId(x) R=50;U=4;Is=1e-12;K=1.38e-23;T=300;q=1.6e-19; Ud=x(1);Id=x(2); f=[Ud+Id*R-U &nbsp; Id-Is*exp(Ud*q/(K*T)-1)]; x = 0.6707 &nbsp; &nbsp;0.0666 &nbsp;Ud &nbsp; &nbsp; &nbsp; &nbsp;Id 5、实验数据处理:已知某压力传感器的测试数据如下表 p 0.0 1.1 2.1 2.8 4.2 5.0 6.1 6.9 8.1 9.0 9.9 u 10 11 13 14 17 18 22 24 29 34 39 p为压力值,u为电压值,试用多项式来拟合其特性函数,求出a,b,c,d,并把拟合曲线和各个测试数据点画在同一幅图上。 p=[0.0 1.1 2.1 2.8 4.2 5.0 6.1 6.9 8.1 9.0 9.9]; u=[10 11 13 14 17 18 22 24 29 34 39]; plot(p,u,&#39;r+&#39;) abcd=polyfit(p,u,3) p1=0:0.1:10; u1=polyval(abcd,p1); hold on plot(p1,u1,&#39;b&#39;); grid hold off axis([-1 11 8 41]); xlabel(&#39;p&#39;); ylabel(&#39;u&#39;); legend(&#39;p-u&#39;,&#39;u(p)=a*p^3+b*p^2+c*p+d&#39;,2) 实验八 MATLAB应用 1、用Simulink求解下图所示电路0~100微秒内的响应。已知R=6*10-4欧,C=1700微法,L=6*10-9享,uc(0)=15kV。 &nbsp; &nbsp; l 模块参数设置: Integrator1的Initial condition:15kV 在命令窗口为R,L,C赋值。 l 仿真参数设置如下: Start time:0 Stop time:100e-6 Solver Type:Variable-step Solver:ode45 Max step size:1e-7 Min step size:auto Initial step size:auto Relative tolerance:1e-3 Absolute tolerance:1e-6 实验四 &nbsp;MATLAB数值运算 一、实验目的:掌握MATLAB常用的数值运算函数。 二、实验内容: 1、求代数方程 p=[3 4 7 2 9 12] roots(p) ans = &nbsp;-0.8612 + 1.4377i &nbsp;-0.8612 - 1.4377i &nbsp; 0.6737 + 1.0159i &nbsp; 0.6737 - 1.0159i &nbsp;-0.9583 &nbsp; 2、求代数方程 p2=[1 0 0 0 0 -1] roots(p2) ans = &nbsp;-0.8090 + 0.5878i &nbsp;-0.8090 - 0.5878i &nbsp; 0.3090 + 0.9511i &nbsp; 0.3090 - 0.9511i &nbsp; 1.0000 &nbsp; 3、求函数)在[0.5,4]区间内的过零点。 fplot(&#39;x^3-2*x^2*sin(x)+5*x*cos(x)+1/x&#39;,[0.5,4]) fzero(&#39;x^3-2*x^2*sin(x)+5*x*cos(x)+1/x&#39;,[0.5,2]) fzero(&#39;x^3-2*x^2*sin(x)+5*x*cos(x)+1/x&#39;,[2,4]) x1 = 1.5117 x2 = 2.6095 4、 已知R=50欧姆,U=4V,二极管D正向电流与电压的关系为: 其中: Ud为二极管正向电压 Is为反向饱合电流,取10-12A K为玻尔茨曼常数,1.38*10-23 T为绝对温度,取300开尔文(27摄氏度) q为电子电荷1.6*10-19C 求此电路中的电流Id和二极管正向电压Ud 解:列电路方程: (1)估计解的位置 R=50;U=4;Is=1e-12;K=1.38e-23;T=300;q=1.6e-19; %Ud+Id*R-U=0; %Id-Is*exp(Ud*q/(K*T)-1)=0; Ud=0:0.01:0.7; Id=Is*exp(Ud*q/(K*T)-1); Ud1=0:0.01:4; Id1=(U-Ud1)/R &nbsp; plot(Ud,1000*Id,&#39;r&#39;) hold on plot(Ud1,1000*Id1,&#39;b&#39;) grid hold off function solve_UdId clc x=fsolve(@UdId,[1 &nbsp;0.05]) function f=UdId(x) R=50;U=4;Is=1e-12;K=1.38e-23;T=300;q=1.6e-19; Ud=x(1);Id=x(2); f=[Ud+Id*R-U &nbsp;Id-Is*exp(Ud*q/(K*T)-1)]; x = &nbsp; &nbsp;0.6707 &nbsp; &nbsp;0.0666 5、求下面函数的极小值点。 [x,y]=meshgrid([-10:0.5:10]); z=x.^2+y.^2-0.5*x.*y-2*sin(x); surfc(x,y,z) f5 = @(x)x(1)^2+x(2)^2-0.5*x(1)*x(2)-sin(x(1)) [min_x_y,min_z] = fminsearch(f5,[1,0]) min_x_y = &nbsp; &nbsp;0.4745 &nbsp; &nbsp;0.1186 min_z = &nbsp; -0.2458 6、建立下图所示电路的数学模型,已知R=6*10-4欧,C=1700微法,L=6*10-9享,uc(0)=15kV,用MATLAB的常微分方程求解器求解0~100微秒内的电路响应。 R L C + - i uc uL + - (t=0) 建立图示电路的数学模型: function slove_rlc [t,x] = ode45(@rlc_0,[0 100e-6],[15e3;0]) plot(t,x(:,1)); figure plot(t,x(:,2)); &nbsp; function dxdt = rlc_0(t,x) R=6e-4;L=6e-9;C=1700e-6; dxdt = [-x(2)/C; (x(1)-R*x(2))/L]; <!--0,则解存在的区间缩小为[x1,xm],否则解存在的区间缩小为[xm,x2]。重复这样的步骤,直到区间的长度小于一个可以接受的小数(比如1e-10),则认为中点即是原方程的解。--></min_x><!--=3--><!--=1e4--><!--70--><!--80--><!--90--><!--=100--><!--0|s--><!--0-->
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 考试专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服