183
社区成员




clc,clear,close all;
%load data
fs = 16000;
n = 0:1000;
myRecording = sin(2*pi*1000/fs*n);
L0= length(myRecording);
t = (0:L0-1)/fs;
% assignin('base','t',t);
x=myRecording;
% assignin('base','x',x);
x_am=(2+x).*cos(2*pi*8000*t);
subplot(221)
plot(t,x);
% plot(app.UIAxes4,t,x);
subplot(222)
plot(t,x_am,'b');
title('调幅信号时域图像');
xlabel('t(s)'), ylabel('幅度')
L1=length(x);
y1=abs(fft(x)/L1);
f1=fs*(0:(L1/2))/L1;
% f1=app.fs*(0:(L1/2))/L1;
subplot(223)
plot(f1,y1(1:L1/2+1)); %绘制频域图像
L=length(x_am);
y=abs(fft(x_am)/L);
L0=length(y);
f=fs*(0:(L0-1))/L;
% f=app.fs*(0:(L0/2))/L;
subplot(224)
plot(f, y, 'b'); %绘制频域图像
title('调幅信号频域图像');
axis([0, 16000, 0, 2]);
xlabel('f(Hz)'), ylabel('幅度');
% save('data.mat', 'x_am')
也可以更换基带信号: