无法获得低通信号及其幅度谱。也无法绘制 x(t) 的同相和正交分量以及 x(t) 的包络。我也附上了这个问题。
代码的错误是什么,我已经定义了函数。仍然无法正常工作。
df=0.5;
ts=0.001;
fs=1/ts;
t=-2:0.001:2;
fo=200;
x=sinc(100*t).*cos(400*pi*t);
plot(t,x);
xlabel('time');
ylabel('x(t)');
y=fftseq(x,ts,df);%calling the function fftseq
N=length(y);
f=([0:N-1]-N/2)*fs/N; % generate frequency vector for plot
y=fftshift(y); % swap lower and upper spectrum halves
plot(f, abs(y));
xlabel('frequency');
ylabel('x(f)');
axis([-500 500]);
xl=loweq(x,ts,fo);%calling the function loweq
plot(abs(x1));
figure
I = real(x1);%real part
Q = imag(x1);%imaginary part
plot(I);
plot(Q);
function xl=loweq(x,ts,f0)
% xl=loweq(x,ts,f0)
%LOWEQ returns the lowpass equivalent of the signal x
% f0 is the center frequency.
% ts is the sampling interval
t=[0:ts:ts*(length(x)-1)];
z=hilbert(x);
xl=z.*exp(-j*2*pi*f0*t);
end
function [M,m,df]=fftseq(m,ts,df)
% [M,m,df]=fftseq(m,ts,df)
% [M,m,df]=fftseq(m,ts)
%FFTSEQ generates M, the FFT of the sequence m.
% The sequence is zero-padded to meet the required frequency resolution df.
% ts is the sampling interval. The output df is the final frequency resolution.
% Output m is the zero-padded version of input m. M is the FFT.
fs=1/ts;
if nargin == 2
n1=0;
else
n1=fs/df;[enter image description here][1]
end
n2=length(m);
n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);
m=[m,zeros(1,n-n2)];
df=fs/n;
end