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.1A = A+1;endy = 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.
Best Answer