One way to approach this problem is to treat it like an optimization with Integer Constraints, where you actually solve for an *index_ _*within the set possible solutions.
There are two primary optimization methods in MATLAB which support integer constraints: the Genetic Algorithm, and Linear Programming, although Linear Programming may not be a good fit for some problems. Even if you could implement an integer constraint on a function like "fmincon", the underlying algorithm would still search on a continuous space which does not make sense and is not efficient given the problem statement.
If the discrete solution space is small enough, you may even consider a direct search of all options, as opposed to some iterative optimization method. This approach may not be feasible if you have for example 40 possible resistor values and you are looking to solve for a vector of 8 resistor values. In such a situation, you end up with a search space of size 40^8 which is quite a few solutions to consider.
There is an example in the documentation which is quite similar to the described problem, and in this case the Genetic Algorithm is used with Discrete Non-Integer Constraints:
In this example, you can use the Genetic Algorithm to solve for an index, (i.e. 3) which then corresponds to some resistor value (i.e. 27.2). Given the inclusion of Integer Constraints, you will always find an exact index corresponding to one available resistor values, successfully implementing Discrete Non-Integer Variable Constraints on the optimization problem.