所以我想模擬下圖所示的系統。我在Matlab中用ODE45模擬過,但由於某種原因,我用下面的代碼得到了一個奇怪的輸出。我不確定是否因爲我放置了if((Vin-Vd-Vc)/ Ll> = 0)的條件,這有助於防止任何電流在反向偏置時流向二極管的錯誤方向。Matlab中的ODE45麻煩與二極管模型
我試圖附上照片,但我的代表不夠高,真的是男性?,所以我必須描述它。
source -> Inductor(Ll) -> diode -> Capacitor -> ground
|->Inductor(Lline)->resistor(Rf) -> ground
任何幫助表示讚賞!
function dy = ThreeLamp(t,y)
I1 = y(1);
I2 = y(2);
Vc = y(3);
Is = 1E-15; % these are parameters for the diode
n = 1.05;
Vt = .025;
D = 24; % this number is from 0 to 50
f = 100E3; % this is the frequency of the input waveform
Ll = 5E-7;
Lline = 5.3E-6;
C = 10E-6;
Rf = 10;
Vin = (465/2)*(6/266)*square(2*pi*f*t,D); % Input voltage waveform
if(Vin < 0)
Vin = 0; % get rid of negative half cycle
end
%%
Vd = n*Vt*log(I1/Is + 1)/log(10); % This is the voltage across the diode
if((Vin - Vd - Vc)/Ll >= 0) % Is the diode conducting when forward biased?
dy(1) = (Vin - Vd - Vc)/Ll; % Sounds good, what is the current?
else
dy(1) = 0; % force current to 0 when reversed biased
end
dy(2) = (Vc - I2*Rf)/Lline; % KCL for second loop
dy(3) = (I1 - I2)/C; % Voltage on cap
dy = dy'; % ODE45 likes output to be in columns
end
% [t, y] = ode45('ThreeLamp',[0 .001],[0 0 0 ]);
爲什麼輸出「奇怪」?你能指望什麼? – horchler
我會嘗試一個僵硬的求解器,比如'ode15s'或'ode23t'。你也可以使用Simulink和Simscape嗎?如果是這樣,有一個電氣元件庫可以使您的系統建模變得更加容易:http://www.mathworks.co.uk/help/physmod/simscape/simscapeblocklist.html – am304
'ode15s'給出了幾乎相同的結果。較小的容差似乎也沒有太大變化。 – horchler