フィルターのクリア

Blocks updates persistent or state variables while computing outputs

24 ビュー (過去 30 日間)
Matteo Paiano
Matteo Paiano 2021 年 9 月 20 日
コメント済み: VIGNESH BALAJI 2024 年 1 月 24 日
In Simulink I had a MATLAB function working properly. I change it a little bit, but now I get the error:
"'DynProg/referenceS/Willners' or the model referenced by it contains blocks that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. The parent subsystem 'DynProg/referenceS' is in an algebraic loop with the following blocks"
function [u_opt,r_des] = optimal_heading(current_X_ASV,X_AUV_list,P_AUV_list,u_max,r_max,Tc_usbl,decisions)
X = current_X_ASV'; Cost = 0; action = [-1 -1]; LA = -1;
coder.varsize('expansion',[10000 7], [1 0])
expansion = [X,Cost,action,LA];
psi_set = (2*r_max*Tc_usbl).*rand(1,decisions) - r_max*Tc_usbl;
u_set = u_max.*rand(1,decisions);
delta_opt = action(1); u_opt = action(2);
r_des = delta_opt/Tc_usbl;
The code is much longer than this, but I tried commenting and uncommenting some lines and I came to the conclusion that the use of rand is somehow responsible for the error. However, if I create a simple function like
function fcn(r_max, Tc_usbl, decisions)
psi_set = (2*r_max*Tc_usbl).*rand(1,decisions) - r_max*Tc_usbl;
for k = 1:numel(psi_set)
delta = psi_set(k)
end
It works fine! The previous version of the function used a simple linspace, and if I still use it instead of rand, the code compile correctly.
Do you have any suggestion! Thanks, really!
  2 件のコメント
Sargondjani
Sargondjani 2021 年 9 月 20 日
what are the state variables? I mean, the error suggests that you change your state variables in the function optimal_heading
VIGNESH BALAJI
VIGNESH BALAJI 2024 年 1 月 24 日
Did you get a solution for this ? I am also facing similar error

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by