How can I specify the inequality signs in the function call?
3 次查看(过去 30 天)
显示 更早的评论
My program is like that
if 2x-5y-6<=0 && 4x-6y+7>=0
........
end
I want a function file for that.
function myprogram(A,b)
I will run it as
>> myprogram([2 -5;4 -6],[6 -7]) How can I specify the inequality signs in the function call
4 个评论
Walter Roberson
2013-10-5
It is the matrix inequality
A*x - b ? 0
where the ? operator may be different for every row and suvadip paul wishes the choice of inequality operators to be user input.
回答(1 个)
Walter Roberson
2013-10-5
myprogram([2 -5;4 -6],[6 -7], {'<=', '>='})
2 个评论
Walter Roberson
2013-10-5
编辑:Walter Roberson
2013-10-5
function myprogram(A, b, user_inequalities)
If you want to figure out which inequality characters were given, use strcmp() or ismember()
Hint: you do not need all four operators. P > Q is the same as -P < -Q
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!