MATLAB课程设计任务书(-)
一、名称: MATLAB编程简介 二、目的
熟悉MATLAB编程环境,掌握Help 命令、基本的变量类型、矩阵的基本运算、基本的绘图函数和M-file的建立。 三、内容 (一) 例 题
例1、 Help 命令 help cos help plot help abs help exp help +
例2、 变量和矩阵运算
(1) Matrix——The basic variable type
M=3
M=[1 2 6]
M=[1 2 6; 4 6 7] M13=M(1,3) size(M)
(2) The Colon Operator ( : )
%Creating Array and Vector % v = start: skip: end x1=0:2:10
x2=0:1:10 (or x=0:10) t=-1:0.2:1
?cessing Matrix
A=[1 2 3;4 5 6;7 8 9] A(2:3,1:2) x2(4:8)
(3) Matrix Operations (A±B)
A=[2 3 4; 6 9 8] B=[1 2 3; 5 8 7] C1=A+B C2=A-B C3=A-4
(4) Matrix Operations (A*B A.*B)
% A*B A=[2 3 4; 6 9 8]
1
B=[1 2; 3 5; 8 7] A*B
% A.*B
A=[2 3 4; 6 9 8] B=[1 2 3 ;5 8 7] A.*B
(5) Matrix Operations (B/A ,A\\C, B./A ,A.\\C)
% B/A —— B*inv(A) % A\\C —— inv(A)*C %B./A —— B(i,j)/A(i,j) %A.\\B —— A(i,j)\\B(i,j)
(6) Matrix Operations ( ^ and .^) % ^ Operation
A=[1 2 3; 4 5 6; 7 8 9] b=A^2 % .^ Operation
A=[1 2 3; 4 5 6; 7 8 9] b=A.^2
(7) Matrix Operations ( A′and A. ′)
% A′共轭转置
a=[1+2i 3+4i; 3+2i 5+5i] a′
% A.′非共轭转置 a.′
例3 、 绘图函数plot(x,y) ,stem(k,y) % plot(x,y) x=0:0.01:2; y=sin(2*pi*x); plot(x,y) % stem(k,y) k=0:50;
y=exp(-0.1*k); stem(k,y)
例4、 M file
% y(t)=sin(2t) + sin(5t) -2pi ≤ t ≤ 2pi t =-2*pi:0.02:2*pi; y=sin(2*t) + sin(5*t); plot(t,y)
(二) 练 习 题
1、 基本命令 help plot
help colon help ops
2
help zeros help ones pi*pi-10
sin(pi/4) ans^2 zz=3+4i; conj(zz)
abs(zz) angle(zz) real(zz) imag(zz)
2、Array Indexing
xx=[ones(1,4),[2:2:11],zeros(1,3)] xx(3:7) length(xx)
xx(2:2:length(xx))
xx(3:7)=pi*(1:5)
3、 用以下语句建立M-file
t=-2:0.05:3;
y=sin(2*pi*0.789*t); plot(t,y), grid on
title('TEST PLOT of SINUSOID') xlabel('TIME(sec)')
(-1?t?2)(用M-file实现) 4、 画出以下信号的波形
x1(t)?2cos(2?t?30?) x2(t)?4cos(2?t?60?)
四、要求
学生对实验练习题编写MATLAB程序并运行,在计算机上输出仿真结果。
3
MATLAB课程设计任务书(二)
一、名称:常见信号的MATLAB表示 二、目的
掌握用MATLAB表示信号与系统中的常见信号, 熟悉MATLAB中一些常用的信号生成函数。 三、内容 (一) 例 题
例1 、 画图表示指数信号y?Aeat, A?1,a??0.4 [MATLAB程序]:
% decaying exponential signal
A=1;a=-0.4; t=0:0.01:10;
ft=A*exp(a*t);
plot(t,ft);grid on;
[运行结果]:
10.90.80.70.60.50.40.30.20.10012345678910例2 、 画图表示正弦信号
y?Asin(?0t??), A?1,?0?2?,???/6
[MATLAB程序]: % sinusoidal signal
A=1;w0=2*pi;phi=pi/6; t=0:0.001:8;
ft=A*sin(w0*t+phi); plot(t,ft);grid on;
[运行结果]:
4
10.80.60.40.20-0.2-0.4-0.6-0.8-1012345678
例3 、 画图表示抽样函数y?sin(?t)/(?t)。(利用函数sinc(t)) [MATLAB程序]: % sample function
t=-3*pi:pi/100:3*pi; ft=sinc(t/pi); plot(t,ft);grid on;
[运行结果]:
例4、 画图表示矩形信号,设幅度A=1,宽度为W=2。 [MATLAB程序]:
% rectangular pulse signal t=0:0.001:4; T=1;
ft=rectpuls(t-2*T,2*T);
plot(t,ft);grid on;axis([0 4 -0.5 1.5]);
[运行结果]:
10.80.60.40.20-0.2-0.4-10-8-6-4-202468101.510.50
例5、 画图表示周期形三角波信号,设幅度A=1,宽度为W=4,斜度k=0.5。 [MATLAB程序]:
% periodic triangular pulse signal
t=-5*pi:pi/10:5*pi; x=sawtooth(t,0.5);
plot(t,x);axis([-16 16 -1.5 1.5]);grid on;
[运行结果]:
-0.500.511.522.533.54 5
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库matlab任务书在线全文阅读。
相关推荐: