门函数 a=10; b=10; c=a-b01a+b; x1=rectpulsc-ab; 定义矩形波的脉宽参数10 10为中心参数 subplot321; plotcx1; ylabelx1n; 衰减函数 t = 00110; x2 =2exp-3t; 2是衰减的强度-3是衰减的速度 subplot322; plottx2; ylabelx2n; N = maxlengthx1 len
在代码中,有两个错误需要进行修改:
-
将
cirshftt函数改为circshift函数,因为MATLAB中没有cirshftt函数。 -
在绘制最后一个图形时,需要删除多余的
plot(n,y)代码。
修改后的代码如下:
a = 10;
b = 10;
c = a-b:0.1:a+b;
x1 = rectpuls(c-a,b); % 定义矩形波的脉宽参数10,10为中心参数
subplot(3,2,1);
plot(c,x1);
ylabel('x1(n)');
%衰减函数
t = 0:0.1:10;
x2 = 2*exp(-3*t); % 2是衰减的强度,-3是衰减的速度
subplot(3,2,2);
plot(t,x2);
ylabel('x2(n)');
N = max(length(x1), length(x2));
n = 0:N-1;
x1 = [x1, zeros(1, N-length(x1))];
subplot(3,2,3);
plot(n,x1);
ylabel('周期延拓');
x2 = [x2, zeros(1, N-length(x2))];
subplot(3,2,4);
plot(n,x2);
ylabel('周期延拓');
x3 = x1(mod(-n, N) + 1);
subplot(3, 2, 5);
plot(n, x3);
ylabel('翻褶');
for m=0:N-1
x4 = circshift(x2, m, N);
x5 = x3.*x4;
y(m+1) = sum(x5);
end
subplot(3,2,6);
plot(n,y);
ylabel('圆周卷积(时域)');
原文地址: https://www.cveoy.top/t/topic/i6dm 著作权归作者所有。请勿转载和采集!