Azzera filtri
Azzera filtri

Embedded Function Error-algebraic loop error message in Simulink

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Kaustubha Govind
Kaustubha Govind il 21 Giu 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 Commenti
iman
iman il 21 Giu 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 il 22 Giu 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by