minimum value of one inequality
Afficher commentaires plus anciens
i need to calculate n which should give minimum even value from the expression. what function should i use to code this.
1/(2^(n/2)) + (r/s)*(1 - 1/(2^(n/2)))<=0.1
if the value of r is known (say=0.001) and s=7;
then if i calculate manually i am getting n>=6.64
but i need minumum even integer so i should get n=8.
want to know how to code these kind of inequality
p.s: i am a beginner
Réponse acceptée
Plus de réponses (1)
Ameer Hamza
le 24 Sep 2020
One way is to use optimization toolbox
fmincon(@(n) n, 0, [], [], [], [], [], [], @nlcon)
function [c, ceq] = nlcon(n)
r = 0.001;
s = 7;
c = 1/(2^(n/2)) + (r/s)*(1 - 1/(2^(n/2))) - 0.05;
ceq = [];
end
4 commentaires
danish ansari
le 24 Sep 2020
Bruno Luong
le 24 Sep 2020
fmincon is not applicable for integer optimization.
John D'Errico
le 24 Sep 2020
GA would work.
Ameer Hamza
le 24 Sep 2020
Oh! I missed the part about the solution being an integer. Yes, ga() will work here.
n = ga(@(n) n, 1, [], [], [], [], [], [], @nlcon, 1);
function [c, ceq] = nlcon(n)
r = 0.001;
s = 7;
c = 1/(2^(n/2)) + (r/s)*(1 - 1/(2^(n/2))) - 0.05;
ceq = [];
end
Catégories
En savoir plus sur Assumptions 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!