1.13算术运算符^和.^之间的区别是什么?
答:算术运算符^表示矩阵乘法,也就是,必须满足前一个矩阵的列数等于后一个矩阵的行数。算术运算符.^表示元素相乘,也就是向量或者矩阵中对应元素相乘。
1.15该序列的长度是多少?怎样才能改变他?
答:运行1.14程序后,得到该序列的长度是36;通过改变“n=0:35”中的“0”或者“35”这个数字可以改变序列的长度。
1.17运行程序P1.4,以产生正弦序列并显示它。
% Program P1_4
% 产生一个正弦序列 n = 0:40;
f = 0.1; phase = 0; A = 1.5; arg = 2*pi*f*n - phase; x = A*cos(arg);
clf; % Clear old graph
stem(n,x); % Plot the generated sequence axis([0 40 -2 2]); grid;
title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude');
axis;
图形显示如下:
1.19该序列的长度是多少?怎样可以改变它?
答:该序列长度为41;;可以通过改变n序列的取值来改变它,例如n=0:50,则序列长度为51,同时应注意axis的x域的取值范围。
1.21 axis和grid命令的作用是什么?
答:axis的命令的作用是手工设置图中坐标的尺度。grid命令是在当前图形上增加或者减少网格线。
1.23修改上述程序,以产生一个长度为50、频率为0.08、振幅为2.5、相移为90度的一个正弦序列并显示它。该序列的周期是多少?
n = 0:49;
f =0.08;
phase = pi/2; A = 2.5; arg = 2*pi*f*n - phase; x = A*cos(arg);
clf; % Clear old graph
stem(n,x); % Plot the generated sequence axis([0 49 -3 3]); grid;
title('正弦序列 Q1.23 f=0.08'); xlabel('时间指标 n');
ylabel('振幅'); axis;
图形显示如下:
1.25在程序P1.4中用stairs命令代替stem命令,运行新程序。新图形与习题 Q1.17和习题Q1.24中产生的图形有什么区别?
n = 0:49;
f =0.08;
phase = pi/2; A = 2.5; arg = 2*pi*f*n - phase; x = A*cos(arg);
clf; % Clear old graph
stairs(n,x); % Plot the generated sequence axis([0 49 -3 3]); grid;
title('正弦序列 Q1.23 f=0.08'); xlabel('时间指标 n'); ylabel('振幅'); axis;
图形显示如下:
这是一个杆状图,stairs是将离散的点通过直线连接起来,stem是直接画离散图,而plot是曲线联合在一起,一般画离散图采用stem进行。
1.27编写一个MATLAB程序,以产生并显示一个长度为75的高斯随机信号,该信号正态分布且均值为0,方差为3.
clf; N=75;
x=0+3*randn(1,N); n=1:N;
stem(n-1,x(n)); title('随机信号'); xlabel('时间指标 n'); ylabel('x'); axis;
图形显示为: