sqrt(complex(x)) error occuring earlier than expected
Afficher commentaires plus anciens
I have a simple simscape model of an object moving on a perimeter of an ellipse. I managed to do this with two prismatic joints and using an ellipse equation I was able to to prescribe motion for the object. When the object hits the pole of an ellipse it should run into error because of sqrt(complex(x)) which is quite obvious. However, it runs into the problem way earlier and I don't know why.
The simulink model looks like this:

and the ellipse equation:
function y = fcn(x)
a=1;
b=1;
y = sqrt((b^2)*(1-x^2/a^2));
The simulation should stop near x=-1, but it stops with the domain error in this value of x:

This is the error:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Domain error. To compute complex results from real x, use 'sqrt(complex(x))'.
Error in sqrt.m (line 13)
coder.internal.error('Coder:toolbox:ElFunDomainError',mfilename);
Error in 'vazba_elipsa/ellipse equation' (line 5)
Could anybody tell me where the problem is ? Thank you for your answers, Ondrej.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Multibody Modeling dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!