昨晚手机在看X信的时候突然黑屏,开机重启都没反应,今天维修师傅说使用时间太长了,还是买个新的吧,心疼银子啊!
这里只放前两个小题的图。
代码:
1、
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.28 \n\n'); banner();
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------
% Computer N-point Circular Convolution
% -------------------------------------------------------------------
n1 = [0:5];
x1 = sin(pi*n1/3);
N1 = length(x1); n2 = [0:7];
x2 = cos(pi*n2/4);
N2 = length(x2); % --------------------------------------------
% 1st way TIME domain
% --------------------------------------------
N = 10;
n = [0:N-1]; y1 = circonvt(x1, x2, N); % --------------------------------------------
% 2nd way ---- circular conv(FREQ domain)
% --------------------------------------------
y2 = circonvf(x1, x2, N); % --------------------------------------------
% 3rd way --- Cir Conv (Circulant Matrix)
% --------------------------------------------
y3 = circonvt_v3(x1, x2, N); figure('NumberTitle', 'off', 'Name', 'P5.28.1 x1(n) and x2(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(n1, x1);
xlabel('n'); ylabel('x1(n)');
title('x1(n), N=6'); grid on;
subplot(2,1,2); stem(n2, x2);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('x2(n)');
title('x2(n), N=8'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.28.1 Cir-Conv, N=10')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, y1);
xlabel('n'); ylabel('y1(n)');
title('Time Domain, y1(n)'); grid on;
subplot(3,1,2); stem(n, y2);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y2(n)');
title('FREQ domain, y2(n)'); grid on;
subplot(3,1,3); stem(n, y3);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y3(n)');
title('Circulant Matrix, y3(n)'); grid on;
运行结果:
计算圆周卷积的两序列
三种方法计算圆周卷积
2、
代码:
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.28 \n\n'); banner();
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------
% Computer N-point Circular Convolution
% -------------------------------------------------------------------
N = 32;
n1 = [0:N-1];
x1 = cos(2*pi*n1/N);
N1 = length(x1); n2 = [0:N-1];
x2 = sin(2*pi*n2/N);
N2 = length(x2); % --------------------------------------------
% 1st way TIME domain
% --------------------------------------------
%N = 10;
n = [0:N-1]; y1 = circonvt(x1, x2, N); % --------------------------------------------
% 2nd way ---- circular conv(FREQ domain)
% --------------------------------------------
y2 = circonvf(x1, x2, N); % --------------------------------------------
% 3rd way --- Cir Conv (Circulant Matrix)
% --------------------------------------------
y3 = circonvt_v3(x1, x2, N); figure('NumberTitle', 'off', 'Name', 'P5.28.2 x1(n) and x2(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(n1, x1);
xlabel('n'); ylabel('x1(n)');
title('x1(n)=cos(2*pi*n1/N), N=32'); grid on;
subplot(2,1,2); stem(n2, x2);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('x2(n)');
title('x2(n)=sin(2*pi*n2/N), N=32'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.28.2 Cir-Conv, N=32')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, y1);
xlabel('n'); ylabel('y1(n)');
title('Time Domain, y1(n)'); grid on;
subplot(3,1,2); stem(n, y2);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y2(n)');
title('FREQ domain, y2(n)'); grid on;
subplot(3,1,3); stem(n, y3);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('n'); ylabel('y3(n)');
title('Circulant Matrix, y3(n)'); grid on;
运行结果:
代码结构都一样
圆周卷积结果