Simulink problem with counter and vector indexing.

3 ビュー (過去 30 日間)
Bhargav Jha
Bhargav Jha 2015 年 8 月 11 日
編集済み: Bhargav Jha 2015 年 8 月 11 日
Hello,
I have a simulink file that reads position from a matrix and a virtual target follows it. Please find the file attached for the diagram.
I will explain briefly about each block:
  • Waypoints is the matrix imported from workspace containing position.
  • Distance and Heading block contains equation to calculate distance of vehicle from the current destination loaded from this matrix. It also calculates the required heading.
  • Matlab function blocks takes the distance as input and increments the counter A. Here is the code for it. This counter is used to select the waypoints using index port.
function y = fcn(u)
global A;
if u<0.1
A = A+1;
end
y = A;
  • Problem: *When i execute this i get an error asSimulink cannot solve the algebraic loop containing 'VirtualTarget/Distance and Heading Calculator/Math Function' at time 0.0 using the TrustRegion-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues. To rule out solver convergence as the cause of this error, either a) switch to LineSearch-based algorithm using set_param('VirtualTarget','AlgebraicLoopSolver','LineSearch') b) reducing the fixed step size. If the error persists in spite of the above changes, then the model is likely ill-defined and requires modification.
But when I manually give index as input it works for that iteration. So I think it is not able to read the position on the very first iteration. Please help me how to solve it. It is a part of my project and deadline is very near.

採用された回答

Sebastian Castro
Sebastian Castro 2015 年 8 月 11 日
Algebraic loops in Simulink happen when you have blocks whose inputs at some time step depend directly on its outputs. This causes Simulink to have to iteratively solve for block outputs, which sometimes may fail. As you see in your error message, this is happening in some Math Function block inside your "Distance and Heading Calculator" subsystem.
The reason you get this is because you are feeding the outputs, Distance and alpha, back without any sort of delay or other way of breaking this loop.
Does your algorithm run at a fixed sample time? If so, you should try place a Unit Delay block (with that sample time) on the feedback path. If your algorithm runs in continuous time, you could try a Memory block instead.
- Sebastian
  1 件のコメント
Bhargav Jha
Bhargav Jha 2015 年 8 月 11 日
編集済み: Bhargav Jha 2015 年 8 月 11 日
Thanks a lot man!! You came as a savior second time today. :) My algorithm was on fixed sample time so I used unit delay block.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by