フィルターのクリア

use of timer for simulating voltage regulator

1 回表示 (過去 30 日間)
Umberto
Umberto 2013 年 3 月 27 日
回答済み: Sabin 2024 年 1 月 22 日
Hello everybody! I need to simulate a voltage regulator: in this system voltage has to be regulated if it's out of tolerance for more than 30 seconds. If voltage returns to the correct range the timer has to be stopped. I wrote this code
function simulation
% parameters
Vnom = 3850;
s = 0.01;
delay = 30;
g = 50;
n = 1000;
Vmin = Vnom*(1-s);
Vmax = Vnom*(1+s);
V = xlsread('data.xls', 1, 'C2:C1002'); %import data from Excel
t = timer('Period', delay, 'TimerFcn', calculate(V, g, n, Vmin, Vmax));
function calculate
for i=1:n
if V(i) < Vmin
start(t);
if "30 seconds are passed"
V(i) = V(i)+ g;
end
elseif V(i) > Vmax
start(t);
if "30 seconds are passed"
V(i) = V(i)- g;
end
elseif (V(i) >= Vmin && V(i) <= Vmax)
stop(t);
end
end
xlswrite('data.xls', V, 1, 'E2:E1002');
Problems:
1)Error message ("Too many input arguments") in this line t = timer('Period', delay, 'TimerFcn', calculate(V, g, n, Vmin, Vmax))
2)How can I express in matlab code the fact that "30 seconds are passed"?

回答 (1 件)

Sabin
Sabin 2024 年 1 月 22 日

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by