我正在尝试模拟非理想的零阶保持,但我的频率会增加。这是我的代码:
amp = 1;
f = 1e9;
fs = 10e9;
phase = 90;
phase = phase/180*pi;
Ts = 1/fs;
start = 0;
cycles = 10;
duration = cycles * Ts;
ts = start:Ts:duration;
vin = amp*cos(2*pi*f*ts + phase);
t = start:0.0001*Ts:duration;
v0 = 0;
vf = vin;
tau = 10e-12;
m = length(t);
n = length(ts);
sections = m/n;
vt = zeros(n,sections);
temp = vector2matrix(t,sections);
for ii = 1:1:n
for jj = 1:1:sections
vt(ii,jj) = vf(ii) + (v0 - vf(ii))*exp(-temp(ii,jj)/tau); %ZOH formula
end
end
vt = vt';
vt = vt(:)';
figure;
plot(t,vt);%xlim([0 0.1e-9]);
hold on
stairs(ts,vf);
hold off
在下图中,当它看起来像橙色轨迹时,我得到蓝色轨迹:
答案 0 :(得分:1)
没有频移,这是因为没有足够的样本跟随蓝线。红色曲线有
ts =1.0e-09 *[0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000]
,因此与蓝色曲线相比,显示功能的点数要少得多。在这些点上,蓝色和红色曲线重合,因此它们是正确的。另一种看待此问题的方法是向ts
添加更多点数。请考虑以下代码:
...
cycles = 12;
duration = cycles * Ts;
ts = start:.8*Ts:duration-.8*Ts;
vin = amp*cos(2*pi*f*ts + phase);
t = start:0.0001*Ts:duration-0.0001*Ts;
...
figure;
plot(t,vt,'k');%xlim([0 0.1e-9]);
hold on
stairs(ts,vf,'y--');
hold off
除ts
的周期数和步数(现在4个样本更长)外,所有代码都相同。获得以下图表:
现在这两个很好地重叠,所以你可以看到没有频移。