How to solve this issue Variable ‘X’ is not fully defined on some execution paths.

Technical Source
2 min readSep 14, 2021

--

Dear All,

I have a code into a MATLABFUNCTION block of Simulink that jump out this error message “

Variable ‘CONDICIONTRAMO’ is not fully defined on some execution paths. Function ‘Battery_Control/Function_Cruz_v2’ (#25.1881.1895), line 57, column 12: “CONDICIONTRAMO” Launch diagnostic report.”

Anyone of you can help me out to find the way to solve this ? Please.

function [SOC_CC, Bat_charge] = BUsage(top, SOC, SOC_Seg, SOCint, W_demand, Power_PV)
if SOC>=SOC_Seg
SOC_CC=0;
Bat_charge=0;
return
else
if SOC>=SOCint
SOC_CC=1;
Bat_charge=0;
end
if SOC<=SOCint

if (top>=8)||(top<=9) && Power_PV>W_demand
CONDICIONTRAMO = 1;
disp('Llano 1 de 8 a 9')
elseif (top>=8)||(top<=9) && Power_PV=10)||(top<=13) && Power_PV>W_demand
CONDICIONTRAMO = 3;
disp('Punta 1 de 10 a 13')
elseif (top>=10)||(top<=13) && Power_PV=14)||(top<=17) && Power_PV>W_demand
CONDICIONTRAMO = 5;
disp('Llano 2 de 14 a 17')
elseif (top>=14)||(top<=17) && Power_PV=18)||(top<=21)&& Power_PV>W_demand
CONDICIONTRAMO = 7;
disp('Punta 2 de 18 a 21')
elseif (top>=18)||(top<=21)&& Power_PV=22)||(top<=23)&& Power_PV>W_demand
CONDICIONTRAMO = 9;
disp('Llano 3 de 22 a 23:59')
elseif (top>=22)||(top<=23)&& Power_PV=24)||(top<=8) && Power_PV

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Insert a definition of CONDICIONTRAMO = -1 (or NaN, or 12) either on top of the code, before the IF branchs, or in a finaly else branch:

...
elseif (top>=24)||(top<=8) && Power_PV

But then Bat_charge is not defined in all branchs. Add a default value for this variable also.

By the way, the Switch/Case-Block is hard to read. Maybe this is tougher:

%               1 2 3 4 5 6 7 8 9 10 11 12
SOC_CC_V = [1 0 1 0 1 0 1 0 1 0 1 NaN];
Bat_charge_V = [0 0 0 0 0 0 0 0 0 0 1 NaN];
SOC_CC = SOC_CC_V(CONDICIONTRAMO);
Bat_charge = Bat_charge_V(CONDICIONTRAMO);

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.