Trying to create .c file, Variable 'complexMat22' is not fully defined on some execution paths.
Show older comments
Hi, for my final project I need to create a .c file from my matlab code to run on a microcontroller. I keep getting the "Variable complexMat22 is not fully defined on some execution paths" error even though I think I cleared all possible scenarios.
the relevant code lines:
r2=find(complexMat2(:,4));
if isempty(r2)~=1
complexMat22=zeros(length(r2),5);
complexMat22(:,:)=complexMat2(r2,:);
boolean55=1;
.
.
.
if boolean5*boolean55==1
for i=1:length(complexMat22(:,4))
.
.
.
end
I tried to make sure complexMat22 is not empty and in fact exists but I still get the error...
Thanks for the help!
1 Comment
Shimmy Hury
on 6 May 2016
Answers (1)
Geoff Hayes
on 6 May 2016
Shimmy - the error message is telling you that the variable complexMat22 is not being defined for all execution paths. It seems that you are creating it in an if block. Is that the only place? If so, then if this block of code is not executed (because r2 is empty) then complexMat22 will not be defined for the other if block where we iterate over each element in this complex matrix.
Try defining this variable outside of the first if statement as
r2=find(complexMat2(:,4));
complexMat22 = [];
if isempty(r2)~=1
% etc.
end
Now, regardless as to whatever execution path is invoked, the variable complexMat22 will be defined.
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!