Why do I receive an error message about output arguments for my Embedded MATLAB Function in Simulink?

4 views (last 30 days)
I have if-else statements in my code to output different results in different situations. When I start the simulation I get the following error message.. I hope you can help me. Thank you
Output argument 'D' is not assigned on some execution paths.
Function 'MPPT /IC Algo' (#182.9.10), line 1, column 10: "D"
function D = InCon(V,I,T)

Answers (2)

Birdman
Birdman on 8 Jun 2018
Simulink wants to know the initial value and size of your output at the very beginning of the simulation. Therefore, add
D=0;
statement to your function at the very beginning. Then, it should work without error.
  3 Comments
Birdman
Birdman on 9 Jun 2018
Then check your if-else statements and make sure that they are being entered because your value should have changed.

Sign in to comment.


Honglei Chen
Honglei Chen on 8 Jun 2018
Your D is undefined for the cases where T<=n*0.005
You can consider add that by adding the else branch to the code, for example,
if T>n*0.005
... % what you have now
else
D = Dold;
end
HTH

Categories

Find more on Startup and Shutdown 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!