我需要对电气整流器进行建模并使用 MATLAB 绘制输入和输出信号。整流器由 RC 电路组成,其充电速度与电压增加的速度一样快,但放电速度较慢,因此输出信号或多或少是平坦的。它应该看起来像这样:
。
我尝试在 MATLAB 上对其进行编码,得到了这个(我的电路对负电压进行整流,但原理相同):
。
为了获得与维基百科相同的数字,我尝试计算下降指数曲线(红色)和上升正弦曲线(蓝色)之间的交点,因此我只需以正确的间隔添加一条正弦曲线和下降指数曲线即可得到输出信号。
这是我的代码:
f=@(x)sin(2*pi*250000*x+pi/2);%oscillateur de référence
f1=@(x)sin(2*pi*250000*x);
g=@(x)exp(-x*10^4);%décharge du détecteur de crête
h=@(x)f(x)-g(x);%intersection des deux fonctions
format long;
inter=fzero(h,[3.82*10^-6,3.90*10^-6]);
y1=g(0:10^-12:inter);
y2=f(inter:10^-12:4*10^-6);
y3=sin(2*pi*250000*(0:10^-12:1*10^-6));
y=-[y3 y1 y2 y1 y2];
y4=-f1(linspace(0,8*10^-6,length(y)));
x=linspace(0,10*10^-6,length(y));%abscisse
plot(x,y,x,y4);
但是为什么我的图形上的曲线之间有间隙?
I need to model an electric rectifier and to plot both in and out signals with MATLAB. The rectifier is made of a RC circuit which charge as fast as the voltage increases but discharges way slower so the out signal is more or less flat. It's supposed to look like that:
.
I tried to code it on MATLAB and I got this (my circuit rectifies negative voltage but same principle):
.
To get the same figure as the one from wikipedia I tried to compute the intersection between the downing exp curve (red) and the rising sinus curve (blue) so I just had to add a sin curve and a downing exp curve at right intervals to get the out signal.
Here is my code:
f=@(x)sin(2*pi*250000*x+pi/2);%oscillateur de référence
f1=@(x)sin(2*pi*250000*x);
g=@(x)exp(-x*10^4);%décharge du détecteur de crête
h=@(x)f(x)-g(x);%intersection des deux fonctions
format long;
inter=fzero(h,[3.82*10^-6,3.90*10^-6]);
y1=g(0:10^-12:inter);
y2=f(inter:10^-12:4*10^-6);
y3=sin(2*pi*250000*(0:10^-12:1*10^-6));
y=-[y3 y1 y2 y1 y2];
y4=-f1(linspace(0,8*10^-6,length(y)));
x=linspace(0,10*10^-6,length(y));%abscisse
plot(x,y,x,y4);
But why is there a gap between the curves on my figure ?
发布评论
评论(1)
您实际上不需要找到交点。您可以通过一系列嵌套的
max()
调用和逻辑运算来重现相同的曲线。这是一个示例:You really don't need to find the intersection points. You can reproduce the same curve with a series of nested
max()
calls and logical operations. Here's an example: