matlab任务书
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
%Accessing Matrix
A=[1 2 3;4 5 6;7 8 9]
A(2:3,1:2)
x2(4:8)
(3) Matrix Operations (A盉)
rA=[2 3 4; 6 9 8]
B=[1 2 3; 5 8 7]
C1=A+B
C2=A-B
C3=A-4
Matrix Operations (A*B A.*B)
% A*B
A=[2 3 4; 6 9 8]
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
Matrix Operations (B/A ,A\C, B./A ,A.\B)
% B/A —— B*inv(A)
% A\C —— inv(A)*C
%B./A —— B(i,j)/A(i,j)
%A.\B ——B(i,j)/A(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
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
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)')
4、 画出以下信号的波形(用M-file实现)
四、要求
学生对实验练习题编写MATLAB程序并运行,在计算机上输出仿真结果。
MATLAB课程设计任务书(二)
一、名称:常