Output argument 'y' is not assigned on some execution paths
Show older comments
Hello, I wrote this code in MATLAB Function and I get this error " Output argument 'y' is not assigned on some execution paths. Function 'Commutation and inverter/Commutation/MATLAB Function' (#41.11.31), line 1, column 12: "commutation_inverter". I don'y know what I'm missing. I hope you can help me.
Thank you !
function y=commutation_inverter(pos,Vs,ea,eb,ec,Ia,Ib,Ic)
if (pos>=0)&&(pos<60)&&(Ic<=0)&&(Ib<=0)
y = [Vs,0.5*(-Vs+ea+eb-2*ec)];
elseif (pos>=0)&&(pos<60)&&(Ic>0)&&(Ib<=0)
y = [Vs,0];
elseif (pos>=0)&&(pos<60)&&(Ic>=0)&&(Ib>0)
y = [Vs,0.5*(-Vs+ea+eb-2*ec)];
elseif (pos>=0)&&(pos<60)&&(Ic<0)&&(Ib>0)
y = [Vs,-Vs];
elseif(pos>=60)&&(pos<120)&&(Ib>=0)&&(Ia>=0)
y=[0.5*(Vs+ea-2*eb+ec),0.5*(Vs-ea+2*eb-ec)];
elseif(pos>=60)&&(pos<120)&&(Ib<0)&&(Ia>=0)
y=[0,Vs];
elseif(pos>=60)&&(pos<120)&&(Ib<=0)&&(Ia<0)
y=[0.5*(Vs+ea-2*eb+ec),0.5*(Vs-ea+2*eb-ec)];
elseif(pos>=60)&&(pos<120)&&(Ib>0)&&(Ia<0)
y=[Vs,0];
elseif(pos>=120)&&(pos<180)&&(Ia<=0)&&(Ic<=0)
y=[0.5*(-Vs+2*ea-eb-ec),Vs];
elseif(pos>=120)&&(pos<180)&&(Ia>0)&&(Ic<=0)
y=[-Vs,Vs];
elseif(pos>=120)&&(pos<180)&&(Ia>=0)&&(Ic>0)
y=[0.5*(-Vs+2*ea-eb-ec),Vs];
elseif(pos>=120)&&(pos<180)&&(Ia<0)&&(Ic>0)
y=[0,Vs];
elseif(pos>=180)&&(pos<240)&&(Ic>=0)&&(Ib>=0)
y = [-Vs,0.5*(Vs+ea+eb-2*ec)];
elseif(pos>=180)&&(pos<240)&&(Ic<0)&&(Ib>=0)
y = [-Vs,0];
elseif(pos>=180)&&(pos<240)&&(Ic<=0)&&(Ib<0)
y = [-Vs,0.5*(Vs+ea+eb-2*ec)];
elseif(pos>=180)&&(pos<240)&&(Ic>0)&&(Ib<0)
y = [-Vs,Vs];
elseif(pos>=240)&&(pos<300)&&(Ib<=0)&&(Ia<=0)
y=[0.5*(-Vs+ea-2*eb+ec),0.5*(-Vs-ea+2*eb-ec)];
elseif(pos>=240)&&(pos<300)&&(Ib>0)&&(Ia<=0)
y=[0,-Vs];
elseif(pos>=240)&&(pos<300)&&(Ib>=0)&&(Ia>0)
y=[0.5*(-Vs+ea-2*eb+ec),0.5*(-Vs-ea+2*eb-ec)];
elseif(pos>=240)&&(pos<300)&&(Ib<0)&&(Ia>0)
y=[-Vs,0];
elseif(pos>=300)&&(pos<360)&&(Ia>=0)&&(Ic>=0)
y=[0.5*(Vs+2*ea-eb-ec),-Vs];
elseif(pos>=300)&&(pos<360)&&(Ia<0)&&(Ic>=0)
y=[Vs,-Vs];
elseif(pos>=300)&&(pos<360)&&(Ia<=0)&&(Ic<0)
y=[0.5*(Vs+2*ea-eb-ec),-Vs];
elseif(pos>=300)&&(pos<360)&&(Ia>0)&&(Ic<0)
y=[0,-Vs];
end
1 Comment
madhan ravi
on 19 Oct 2018
Can you provide the input datas?
Accepted Answer
More Answers (1)
Walter Roberson
on 19 Oct 2018
Edited: Walter Roberson
on 19 Oct 2018
0 votes
y is not assigned to for negative pos.
I did not bother to track down where there are any other cases.
1 Comment
Walter Roberson
on 19 Oct 2018
fail if pos is nan
fail if pos < 0
fail if pos >= 360
fail if pos > 0 & pos < 120 & Ib is nan
fail if pos >= 120 & pos < 240 & Ic is nan
... and others.
Categories
Find more on Logical 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!