필터 지우기
필터 지우기

Embedded Function Error-algebraic loop error message in Simulink

조회 수: 1 (최근 30일)
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

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 6월 21일
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
iman
iman 2012년 6월 21일
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 2012년 6월 22일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by