1

抱歉,如果我的标题含糊不清,但我创建了一个由 2 个以前的采样波形图(奈奎斯特频率)组合而成的正弦波。我还尝试创建一个干图,其输出的意图看起来像正弦波被离散采样,如下所示:

我确实设法成功地获得了浪潮,但至于其余部分最终看起来像这样:

这是我的代码:

%Time Base
t = 0:0.001:1.8;

%Nyquist Frequencies
Fn1 = 1;
Fn2 = 6;

%Nyquist Rates 
Fnr1 = 2*(Fn1);
Fnr2 = 2*(Fn2);

%Sampling Period
Sp1 = 5*(Fnr1);
Sp2 = 5*(Fnr2);

Ts1 = 1/(Sp1);
Ts2 = 1/(Sp2);
T1 = 1/(Fn1);
T2 = 1/(Fn2);

%Number of Samples
N1 = (T1/Ts1); 
n1 = 0:1:N1; 
N2 = (T2/Ts2); 
n2 = 0:1:N2; 

nTs1 = n1 * Ts1; 
nTs2 = n2 * Ts2; 
x_c = sin(2*pi*Fn1*nTs1);
x_c1 = sin(2*pi*Fn1*t);

x_c2 = sin(2*pi*Fn2*nTs2);
x_2 = sin(2*pi*Fn2*t);

signal = x_c1 + x_2;
ct = nTs1 + nTs2;
nqsignal = x_c + x_c2;

%Second Part
h = stem(ct, nqsignal, 'linewidth', 2);
hold
plot(t, signal, 'linewidth', 2)
lgd = legend('Discrete Data', 'Continuous Data');
set (lgd, "fontsize", 12)
set(gca,'XTick',[0:0.2:1.8]);
set(gca,'YTick',[-2:0.5:2]);
title('Time vs Magnitude','fontweight','bold','fontsize',16);
xlabel('Time','fontweight','bold','fontsize',14)
ylabel('Magnitude','fontweight','bold','fontsize',14)
grid

我认为,就像正弦波一样,我可以简单地添加值来创建变量“nqsignal”,不幸的是无法正常工作并产生不准确的输出。

4

0 回答 0