Output argument is not assigned on some execution paths.

조회 수: 9 (최근 30일)
Faiz Akbar Raihananda
Faiz Akbar Raihananda 2020년 1월 17일
답변: James Tursa 2020년 1월 17일
Hello, I'm trying to code a controller block on simulink using matlab script, but everytime it runs an error that reads "Output argument 'WT2' is not assigned on some execution paths." pops up. Here is my code..
function [WT2, WT3, WT4] = Controller(wt1p, WTC, PV, Demand, Pbattery, SOC)
imbalance = abs(Demand) - PV - WTC;
if imbalance > 0 % SHORTAGE, battery starts supplying to bridge imbalance gap
if 2*wt1p > imbalance >= wt1p
WT2 = 1;
WT3 = 0;
WT4 = 0;
elseif 3*wt1p > imbalance >= 2*wt1p
WT2 = 1;
WT3 = 1;
WT4 = 0;
elseif imbalance >= 3*wt1p
WT2 = 1;
WT3 = 1;
WT4 = 1;
else %When imbalance < wt1p
WT2 = 0; %battery should start supplying in this situation
WT3 = 0; %and also when all the wind turbines are on but imbalance >0
WT4 = 0;
end
elseif imbalance <= 0 %%SURPLUS%%
if SOC >= 0.75
if 0 > imbalance >= -wt1p && WTC == 4*wt1p
WT2 = 1;
WT3 = 1;
WT4 = 0;
elseif 0 > imbalance >= -wt1p && WTC == 3*wt1p
WT2 = 1;
WT3 = 0;
WT4 = 0;
elseif 0 > imbalance >= -wt1p && WTC == 2*wt1p
WT2 = 0;
WT3 = 0;
WT4 = 0;
elseif -wt1p > imbalance >= -2*wt1p && WTC == 4*wt1p %%FINISH THIS YO!!!
WT2 = 1;
WT3 = 1;
WT4 = 0;
elseif -wt1p > imbalance >= -2*wt1p && WTC == 3*wt1p
WT2 = 1;
WT3 = 0;
WT4 = 0;
elseif -wt1p > imbalance >= -2*wt1p && WTC == 2*wt1p
WT2 = 0;
WT3 = 0;
WT4 = 0;
elseif -2*wt1p > imbalance >= -3*wt1p && WTC == 4*wt1p
WT2 = 1;
WT3 = 1;
WT4 = 0;
elseif -2*wt1p > imbalance >= -3*wt1p && WTC == 3*wt1p
WT2 = 1;
WT3 = 0;
WT4 = 0;
elseif -2*wt1p > imbalance >= -3*wt1p && WTC == 2*wt1p
WT2 = 0;
WT3 = 0;
WT4 = 0;
elseif -3*wt1p > imbalance && WTC == 4*wt1p
WT2 = 1;
WT3 = 1;
WT4 = 0;
elseif -3*wt1p > imbalance && WTC == 3*wt1p
WT2 = 1;
WT3 = 0;
WT4 = 0;
elseif -3*wt1p > imbalance && WTC == 2*wt1p
WT2 = 0;
WT3 = 0;
WT4 = 0;
else %if imbalance == 0
WT2 = 1; %%%
WT3 = 0; %%%
WT4 = 0; %%%
end
else %if SOC < 75, battery charges (takes adv. of imbalance)
WT2 = 1;
WT3 = 1;
WT4 = 1;
end
end
I'm pretty sure that every possible execution path has already been included. Which part am I missing?

채택된 답변

James Tursa
James Tursa 2020년 1월 17일
What happens if you change this
elseif imbalance <= 0
to this
else

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multicore Processor Targets에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by