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

1 Ansicht (letzte 30 Tage)
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

Antworten (1)

Chunru
Chunru am 5 Okt. 2023
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

Community Treasure Hunt

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

Start Hunting!

Translated by