资源描述:
《系统仿真实验结果》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验一matlab中矩阵与多项式的基本运算eye(m):产生m*m维的单位矩阵例:»a=eye(3)a=1000100012^ones(n):产生n*n维的全1矩阵ones(m,n):产生m*n维的全1矩阵例:»a=ones⑷a=1111111111111111»3=ones(4,3)a二1111111111113、zeros(m,n):产生m*n维的全0矩阵例:»a=zeros(4,3)0000000000004、rand(m,n):产生m*n维平均分彳j的概率矩阵例:>>a=rand(2,3)0.814
2、70.90580.12700.91340.63240.09755、diag(v):以向量v的元素作为矩阵X的第k条对角线元素,当k二0时,v为X的主对角线;当k>0时,v为上方第k条对角线;当k<0时,v为下方第k条对角线例:»v=[123];»x=diag(v)100020003»v=[l23];»x=diag(v,l)0100000000200300»v=[l23];»x=diag(v,-l)00100200000000306、AB:左除,是方程AX二B的解,RAB=AA-1BA/B:右除,是方程X
3、B=A的解,且A/B=ABA-1lnv(A)*B:B*inv(A)例:a=[123234573];b=[121123456];»x=ab-2.16672.3333-0.16673.3333-1.66670.3333-1.33331.6667-0.3333»a=[123234573];»b=[121123456];»x二inv(a)*b-1.3333-2.16673.33331.66672.3333-1.6667-0.3333-0.16670.3333»a=[123234573];b=[121123456]
4、;»x二inv(b)*aX=0.50000.1667-4.166700.66673.33330.50000.50000.50007、roots(p)»p=[1-6-72-27];r=roots(p)12.1229-5.7345-0.38848、poly:»p=[l35]»poly(p)ans二1-99^conv:deconv:conv([2,4],[4,l])ans=8184»deconv([2,4],[4,l])ans=0.500010、A*B与A.*B的区别»a=magic(3)a=816357492»
5、b=rand⑶3)0.25430.92930.25110.81430.35000.61600.24350.19660.4733a*bans=4.30978.96375.46446.53895.91397.14658.83277.26017.49532.03430.92931.50652.44291.74994.31230.97411.76940.9466who与whos的使用»a=magic(4)a=16231351110897612414151»b=eye(4)b=1000010000100001»who
6、Yourvariablesare:ansba4x4128doubleans3x372doubleb4x4128doubleP1x324doubler3x124doubleSizeBytesClass3x496double»whosNameAttributes12^dispsize(a)length(a)»a=magic(3)816357492»size(a)ans=33»disp(a)816357492»length(a)ans=3实验二基木命令训练1、Polt:绘制二维曲线最基本的函数»t=0:pi/10
7、0:2*pi;»alpha=3;»y=sin(alpha*t);»plot(t,y)2、loglog:对数图3、semilogx:半对数图4^semilogy:半对数图»clear;»x=0:1000;y=0:1000;»subplot(2,2,l);»plot(x,y);title('plot');gridon;»subplot(2,2,2);»semilogx(x,y);title('semilogyx');gridon;»subplot(2,2,3);»semilogy(x,y);title(,sem
8、ilogy');gridon;»subplot(2,2/4);»loglog(x,y);title('loglog,);gridon5、polar:极坐标图»t=0:0.01:3*pi;»polar(3*t,sin(t).*cos(2*t))2403006、title:添加标题7、xlabel:添加横坐标8、ylabel:添加纵坐标9、text:通过text(x,y/string')命令在图形坐标(x,y)处书写