Embedded Matlab function, simulink loop

Hello.
I have been working with the matlab Embedded function in simulink and I have a problem. I am doing an on-off controller by adding many if statements like this:
if a>10
a=-1;
else
a=9;
end
In this case, a is an input and an output, so I need to feedback it. I have tried to feedback it by conect them directly, by using the workspace and using a Memory block, however I always get this warning:
"Found algebraic loop containing..."
The result is the simulation runs for some seconds but suddently it stops without a reason.
How can I solve this problem?
Thanks

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 6 月 11 日

0 投票

How about if you insert a Unit Delay block in the feedback loop?

3 件のコメント

Robinson Medina
Robinson Medina 2012 年 6 月 11 日
Hello.,
Thanks for your answer... I have tryed but it did not work, simulation is still unstable. Is there any command in the embedded Matlab Function block in simulink, that let me save a varible until the next sample time? That could solve my problem.
Regards
Nicholas
Nicholas 2012 年 6 月 11 日
Have you considered using a persistent variable type?
http://www.mathworks.com/help/techdoc/ref/persistent.html
Kaustubha Govind
Kaustubha Govind 2012 年 6 月 13 日
Robinson: Could you explain what you mean by "unstable" - did you mean in the context of controller dynamics? Did the error about algebraic loops go away though?
Nicholas' comment answers the rest of your question.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

製品

質問済み:

2012 年 6 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by