Output argument 'S1' is not assigned on some execution paths.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abdulwasiu Yusuf
le 28 Jan 2020
Réponse apportée : Abdulwasiu Yusuf
le 29 Jan 2020
Hi.
I'm trying to implement Space Vector PWM. I created a function to calculate my time and as well as the switching time for the inverter.
I however get "Output argument 'S1' is not assigned on some execution paths." as the error. I have looked through and try out diffrent approach, nothing seems to work.
Please i need help to resolve this persistent error.
I have also attached a copy of the file. (downgarded to 2013version)
This is the complete Matlab function.
% I have 3 input into the function block%
% The Magnitude, the Angle (radian) and the Sequence block in that order%
% The output goes to my inverter IGBT's swith input%
function [S1,S3,S5,S4,S6,S2] = fcn(u)
b = sqrt(3);
Vdc = 400;
Fs = 5000;
Ts = 1 / Fs;
m = pi/3;
Alpha = u(2);
A = b * Ts * u(1) / (Vdc);
if (Alpha > 0) && (Alpha <= m)
K =1; %for sector 1%
Ta = A * sin((K * m) - Alpha);
Tb = A * sin(Alpha);
To = Ts - Ta - Tb;
a = To/4;
b = Ta/2;
c = Tb/2;
d = To/2;
T = [a b c d c b a];
T_T = cumsum(T);
SA = [0 1 1 1 1 1 0];
SB = [0 0 1 1 1 0 0];
SC = [0 0 0 1 0 0 0];
for e = 1:7
if(u(3) < T_T)
break
end
end
S1 = SA(e);
S3 = SB(e);
S5 = SC(e);
S4 = 1-SA(e);
S6 = 1-SB(e);
S2 = 1-SC(e);
end
0 commentaires
Réponse acceptée
Image Analyst
le 29 Jan 2020
Have the first lines right after the function line be assignments for the S's.
S1 = nan; % or zero or -inf or whatever you want.
S3 = nan;
S5 = nan;
S4 = nan;
S6 = nan;
S2 = nan;
That way, not matter what happens (like you don't assign them afterwards for whatever reason, which is what happened), they will at least have a value and that particular error won't happen.
2 commentaires
Plus de réponses (2)
Walter Roberson
le 28 Jan 2020
When
if (Alpha > 0) && (Alpha <= m)
is false, then you do not assign any value to S1.
There might be other constraints in the model that force u(2) to always be in the range eps(realmin) to pi/3 so it might be a problem more in theory than in practice, but the optimizer doesn't know anything about that.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!