?? ex1_3.m
字號:
%1-3
% Q1.17
clear
clf
n=0:40;
f=0.1;
phase=0;
A=1.5;
arg=2*pi*f*n-phase;
x=A*cos(arg);
figure(1)
subplot(411),stem(n,x),axis([0 40 -2 2]),grid on
title('正弦序列 f=0.1'),xlabel('時間序號 n'),ylabel('振幅')
% Q1.20
eng=sum(x.*x);
te=strcat('序列平均冪',num2str(eng));
text(15,1.7,te)
%Q1.22
n1=[0:40;0:40];
f1=[0.9;1.1];
phase1=[0;0];
A1=[1.5;1.5];
for k=1:2
arg1(k,:)=2*pi*f1(k,1)*n1(k,:)-phase1(k,1);
x1(k,:)=A1(k,1)*cos(arg1(k,:));
end
subplot(412),stem(n1(1,:),x1(1,:)),axis([0 40 -2 2]),grid on
title('正弦序列 f=0.9'),xlabel('時間序號 n'),ylabel('振幅')
subplot(413),stem(n1(2,:),x1(2,:)),axis([0 40 -2 2]),grid on
title('正弦序列 f=1.1'),xlabel('時間序號 n'),ylabel('振幅')
% Q1.23
n=0:50;f=0.08;phase=90;A=2.5;
arg=2*pi*f*n-phase;
x=A*cos(arg);
subplot(414),stem(n,x),axis([0 40 -2.8 2.8]),grid on
title('正弦序列 f=0.01 A=2.5 phase=90'),xlabel('時間序號 n'),ylabel('振幅')
figure(2)
n=0:40;f=0.1;phase=0;A=1.5;
arg=2*pi*f*n-phase;
x=A*cos(arg);
subplot(311),stem(n,x),axis([0 40 -2 2]),grid on
title('正弦序列 f=0.1 stem'),xlabel('時間序號 n'),ylabel('振幅')
% Q1.24
subplot(312),plot(n,x),axis([0 40 -2 2]),grid on
title('正弦序列 f=0.1 plot'),xlabel('時間序號 n'),ylabel('振幅')
% Q1.25
subplot(313),stairs(n,x),axis([0 40 -2 2]),grid on
title('正弦序列 f=0.1 stairs'),xlabel('時間序號 n'),ylabel('振幅')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -