Clear Filters
Clear Filters

Embedded Function Error-algebraic loop error message in Simulink

1 view (last 30 days)
Hi,Help please,when i try to run my Simulink model, i obtain this error:
Cannot solve algebraic loop involving 'Nussbaum/Switch' because it consists of blocks that cannot be assigned algebraic variables, i.e., blocks with discrete-valued outputs, blocks with non-double or complex outputs, Stateflow blocks, or nonvirtual subsystems

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 21 Jun 2012
Do you have an output connect as an input (in a loop)? Perhaps you might want to avoid the algebraic loop in the first place so that Simulink doesn't have to solve it. Please see What are algebraic loops in Simulink and how do I solve them? and this blog post: http://blogs.mathworks.com/seth/2008/07/03/how-did-i-get-an-algebraic-loop-error-when-the-diagnostic-was-set-to-warning/
Also, this previously answered question has a lot of good tips: http://www.mathworks.com/matlabcentral/answers/34478-is-this-the-way-to-solve-algebraic-loops
  2 Comments
iman
iman on 21 Jun 2012
Dear Kaustubha,
thank you for your help so very much!!!
I solved my problem related to this error,but in this simulink model i use another Embedded MATLAB block and i have a new error as following:
Output argument 'sn1' is not assigned on some execution paths.
Code generation failed Errors occurred during parsing of MATLAB function 'Nussbaum/Nussbaum4'
Errors occurred during parsing of MATLAB function 'Nussbaum/Nussbaum4'
this is my code in embedded:
function sn1 = fcn(xs,sn,SN)
%eml
sn = sign(sn);
if sn == +1
if SN <= xs^1.5, sn1 = 1;
elseif SN > xs^1.5, sn1 = -1; end
elseif sn == -1
if SN < -xs^1.5, sn1 = 1;
elseif SN >= -xs^1.5, sn1 = -1; end
else
sn1=1;
end
Please Help me!!!
Kaustubha Govind
Kaustubha Govind on 22 Jun 2012
Iman: Ideally, you should post this as a new question, but I'll try and answer it anyway. I think you need to "pre-allocate" sn1. Just add something like "sn1=0" before the if block.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions 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!