I am getting the error message "Variable 'D' is not fully defined on some execution paths." for this code. please help me
Answers (1)
Hi,
i think your code does not cover all possible cases. If variable T <= 0.02 when calling the function e.g. x = mpp(10, 0.005) then variable D will not be intialised (because n=1) due to the complete following section of code will not be executed:
if(T>0.02*n)
n=n+1;
if (a>0)
D = D0 + delD;
elseif (a<0)
D = D0- delD;
else
D= D0;
end
end
The next section of code will never be true (and due to that never be executed), because you initialise both with values different from zero (when starting your code V0 is always empty, afterwards it is also initialised with values different from Zero):
if (dV==0)|(delD==0)
D = D0;
end
Finally the next section of code will produce error, because there is no value for D to compare with Dmax oder Dmin:
if D>=Dmax | D<=Dmin
D = D0;
end
So when using values for T <= 0.02 when calling the function D will never get a value...
That helped?
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!