修改后的代码如下:

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('翻褶'); 

y = zeros(1, N); % 初始化y向量
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('圆周卷积(时域)');
在代码中有两个错误需要进行修改: 1 将cirshftt函数改为circshift函数因为MATLAB中没有cirshftt函数。 2 在绘制最后一个图形时需要删除多余的plotny代码。 修改后的代码如下: a = 10; b = 10; c = a-b01a+b; x1 = rectpulsc-ab; 定义矩形波的脉宽参数1010为中心参数 subplot321; plotcx1;

原文地址: https://www.cveoy.top/t/topic/i6du 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录