Tolerance in mathematical comparison
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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?
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!