Trying to create .c file, Variable 'complexMat22' is not fully defined on some execution paths.
显示 更早的评论
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 个)
Geoff Hayes
2016-5-6
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!