Greetings! I'm looking for assistance in understanding what's causing the problem in my code.

조회 수: 1 (최근 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
Chunru 2023년 10월 5일
y = determineMode(4, 5, 6, 1, 2)
teg = 4
pv = 5
pzt = 6
D = 2
y = 1
y = 1
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

카테고리

Help CenterFile Exchange에서 Converters (High Power)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by