Tolerance in mathematical comparison

3 vues (au cours des 30 derniers jours)
Ralf Sch
Ralf Sch le 13 Mai 2013
Hey I have a problem, in my code I have this mathematical comparison: inf=(Ttot>=0).*(Ttot+(inp_u~=0).*Tm0+(inp_u~=1).*Te0>Te+Tm); the problem is that this inequality has a problem with small tolerances. When I calculate the comparison by hand, I come normally to an error of around 0.0001. This error is follow by a infeasible state in my code. Is there a possibility to add a tolerance to this inequality? This is only a part of the total feasibility statement. so it is not easily rewritten. Thank you in advance, Kind regards Ralf

Réponse acceptée

Image Analyst
Image Analyst le 13 Mai 2013
"inf" means infinity and you shouldn't assign it to some kind of weird mish-mash of logical expressions and multiplications. What is Ttot? Is it a double number? If so Ttot>=0 is a logical.
OK look at the next term: (Ttot+(inp_u~=0)). So what is inp_u? Is it a number? If so then inp_u~=0 is a logical (True or false). So then you're adding a number to a logical.
And then it just go on with all kinds of strange operations. I'm not sure of the class of any of these variables, and I don't know what you want to do. What are all these things: Ttot, inp_u, Tm0, Te0, Te, and Tm??? What are you trying to see is within a tolerance of something else? What are the two things, and what variable is the tolerance?

Plus de réponses (1)

Ralf Sch
Ralf Sch le 14 Mai 2013
Thank you for your answer. I found the solution already. Thank you anyway

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by