why do i receive "Errors occurred during parsing of MATLAB function"?
6 views (last 30 days)
Show older comments
This is my matlab function called in simulink:
function sgn = fcn(ierr,irif)
%#codegen
if ierr>(irif+10/100*irif+5)
for ierr=ierr:(irif-10/100*irif-5)
sgn=700;
end
else
sgn=0
end
if ierr<(irif-(10/100*irif)-5)
for ierr=ierr:(irif+10/100*irif+5)
sgn=-700;
end
else
sgn=0;
end
0 Comments
Accepted Answer
Jan
on 3 Nov 2015
What is the purpose of this block:
for ierr = ierr:(irif-10/100*irif-5)
sgn = 700;
end
Using the same identifier as loop counter and to define the vector of loop indices is a very strange idea. But the loop is not useful at all, because sgn is overwritten multiple times with the same value.
Perhaps you want this:
function sgn = fcn(ierr,irif)
%#codegen
sgn = 0;
if ierr > (irif+10/100*irif+5)
sgn=700;
elseif ierr < (irif-(10/100*irif)-5)
sgn=-700;
end
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!