Why does my model fail using ELSEIF in an Embedded MATLAB Function Block in Simulink 6.1(R14SP1)?
Show older comments
My model does not work if I use ELSEIF in an Embedded MATLAB Function Block in Simulink 6.1(R14SP1). The code in my Embedded MATLAB Function Block is below:
function y = fcn(u)
% This block supports an embeddable subset of the MATLAB language.
% See the help menu for details.
if (u<0)
x = 1;
elseif (u>=0)
x = 2;
end
y = x/2;
When I try to run my model, I get the following error:
Variable x must be unambiguously written to before use.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink 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!