Tolerance in mathematical comparison

조회 수: 9 (최근 30일)
Ralf Sch
Ralf Sch 2013년 5월 13일
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

채택된 답변

Image Analyst
Image Analyst 2013년 5월 13일
"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?

추가 답변 (1개)

Ralf Sch
Ralf Sch 2013년 5월 14일
Thank you for your answer. I found the solution already. Thank you anyway

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by