华工信号与系统实验(一)--用matlab画信号

直接给出实验要求:
在这里插入图片描述
在这里插入图片描述
题目一

%第1题
%题(1)
subplot(2,2,1);
t1 = -1:0.01:5;
u1 = rectpuls(t1-3,4);
x1 = -2 * u1;
plot(t1,x1)
axis([-1 5 -3 1]);
title('x(t) = -2u(t-1)');
xlabel('t');

%题(2)
subplot(2,2,2);
t2 = 0:0.1:30;
x2 = sin(2*t2/3) .* exp(-0.1*t2);
plot(t2,x2)
xlabel('t');
title('exp(-0.1t)* sin(2t/3)')

%题(3)
subplot(2,2,3);
t3 = -0.1:0.01:0.1;
x3 = cos(100*t3) + cos(3000*t3);
plot(t3,x3)
xlabel('t');
title('cos(100t) + cos(3000t)');

%题(4)
subplot(2,2,4);
t4 = 0:5:200;
x4 = cos(0.1*pi*t4).*cos(0.8*pi*t4);
plot(t4,x4);
xlabel('t');
axis([0 200 -2 2])
title('cos(0.1\pit)cos(0.8\pit)')

题目二

%第2题

%题(1)
subplot(2,1,1);
k1 = -14:15;
x1 = [zeros(1,9), ones(1,11), zeros(1,10)];
stem(k1,x1);
xlabel('k')
title('x[k]');

%题(2)
subplot(2,1,2);
k2 = -19:20;
x2 =(0.9).^k2.*[sin(0.25*pi*k2)+cos(0.25*pi*k2)];
stem(k2,x2);
xlabel('k');
title('x[k]=(0.9)^k[sin(0.25\pik)+cos(0.25\pik)]')

题目三

%第3题
%题(1)
format long
k=-100:1e6;
u = (k>=0);
x = (0.5).^k.*u;
E = sum(abs(x).^2)

%题(2)
k1 = -100:10;
k2 = -100:20;
k3 = -100:30;
u1 = (k1>=0);
u2 = (k2>=0);
u3 = (k3>=0);
x1 = (0.5).^k1.*u1;
x2 = (0.5).^k2.*u2;
x3 = (0.5).^k3.*u3;
E1 = sum(abs(x1).^2)
E2 = sum(abs(x2).^2)
E3 = sum(abs(x3).^2)
p1 = E1/E;
p2 = E2/E;
p3 = E3/E;
fprintf('p1 = %.16f\n',p1)
fprintf('p2 = %.16f\n',p2)
fprintf('p3 = %.16f\n',p3)

题目四

%第4题
clc;
x = [1 2 0 -1 3 2];
h = [1 -1 1];


%题(1)
subplot(2,1,1)
y = conv(x,h)
t = -2:length(y)-3;
stem(t,y)
title('y[k] = x[k] * h[k]')
xlabel('k')

%题(2)
subplot(2,1,2);
R = xcorr(x,y)
m = (length(R) - 1)/2;
stem([-m:m], R);
xlabel('k');
title('R_xy[k]')

题目五

%第5题
clc;

N = 50;
k = 0:N-1;
s = cos(0.08 * pi * k);
d = rand(1,N);

%题(1)
x = s + d;

figure(1)
subplot(3,1,1);
stem(k,s);
xlabel('k');
title('s[k]')

subplot(3,1,2);
stem(k,d);
xlabel('k');
title('d[k]')

subplot(3,1,3);
stem(k,x);
xlabel('k');
title('x[k]=s[k]+d[k]')



%题(2)
figure(2)
h = [1 1 1];
y = conv(x,h)
subplot(3,1,1);
n = 0:length(y)-1;
stem(n,y)
xlabel('n');
title('y[k]=x[k]*h[k]')

subplot(3,1,2);
stem(k,s)
xlabel('k');
title('s[k]');


subplot(3,1,3);
stem(k,x)
xlabel('k');
title('x[k]');

或许有些地方做错了,欢迎纠错~

  • 3
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值