Greetings! I'm looking for assistance in understanding what's causing the problem in my code.
4 次查看(过去 30 天)
显示 更早的评论
this is the MATLAB code:
function y = determineMode(teg, pv, pzt, ~, D, ~, ~, ~, ~)
% Inputs:
% teg: Voltage from TEG source
% pv: Voltage from PV source
% pzt: Voltage from PZT source
% battery: Battery voltage
% D: Duty cycle (0 to 1) for switching between buck and boost modes
% Initialize mode to 'Battery' as the default mode
mode = "Battery"; % Default mode as a string
% Declare MOSFET variables
mosfet1 = 0;
mosfet2 = 0;
mosfet3 = 0;
mosfet4 = 0;
% Check available source and set the mode accordingly
if teg >= 0.3 && teg <= 0.4
% TEG source is available, set mode to 'Boost'
mode = "Boost"; % Set mode as a string
% Set MOSFET states for Boost mode
mosfet1 = 1;
mosfet2 = 1 - D;
mosfet3 = 0;
mosfet4 = D;
elseif pv >= 0.4 && pv <= 1.2
% PV source is available, set mode to 'Boost'
mode = "Boost"; % Set mode as a string
% Set MOSFET states for Boost mode
mosfet1 = 1;
mosfet2 = 1 - D;
mosfet3 = 0;
mosfet4 = D;
elseif pzt >= 1.2 && pzt <= 2.0
% PZT source is available, set mode to 'Buck'
mode = "Buck"; % Set mode as a string
% Set MOSFET states for Buck mode
mosfet1 = 1 - D;
mosfet2 = 0;
mosfet3 = D;
mosfet4 = 1;
end
end
回答(1 个)
Chunru
2023-10-5
y = determineMode(4, 5, 6, 1, 2)
function y = determineMode(teg, pv, pzt, ~, D, ~, ~, ~, ~)
% Inputs:
% teg: Voltage from TEG source
% pv: Voltage from PV source
% pzt: Voltage from PZT source
% battery: Battery voltage
% D: Duty cycle (0 to 1) for switching between buck and boost modes
% Initialize mode to 'Battery' as the default mode
teg, pv, pzt, D
mode = "Battery"; % Default mode as a string
% Declare MOSFET variables
mosfet1 = 0;
mosfet2 = 0;
mosfet3 = 0;
mosfet4 = 0;
% Check available source and set the mode accordingly
if teg >= 0.3 && teg <= 0.4
% TEG source is available, set mode to 'Boost'
mode = "Boost"; % Set mode as a string
% Set MOSFET states for Boost mode
mosfet1 = 1;
mosfet2 = 1 - D;
mosfet3 = 0;
mosfet4 = D;
elseif pv >= 0.4 && pv <= 1.2
% PV source is available, set mode to 'Boost'
mode = "Boost"; % Set mode as a string
% Set MOSFET states for Boost mode
mosfet1 = 1;
mosfet2 = 1 - D;
mosfet3 = 0;
mosfet4 = D;
elseif pzt >= 1.2 && pzt <= 2.0
% PZT source is available, set mode to 'Buck'
mode = "Buck"; % Set mode as a string
% Set MOSFET states for Buck mode
mosfet1 = 1 - D;
mosfet2 = 0;
mosfet3 = D;
mosfet4 = 1;
end
% need to define the output
y = 1;
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!