Evaluate many possible logical expressions
Mostrar comentarios más antiguos
I have a set of binary variables: a,b,c... and a set of rules = { 'a or b', 'a or (b and c)', ... I need a fast way to determine the outcome of rules(i). Creating a truth table is not feasible because the number of binary variables is in the order of ~1000.
8 comentarios
Walter Roberson
el 10 de Jun. de 2017
Are the binary variables definite values that you want to use to evaluate the rules at?
What form are the rules in? Are they literally character vectors like 'a or (b and c)' that would each need to be examined to figure out the corresponding MATLAB code?
Opt User
el 10 de Jun. de 2017
Opt User
el 10 de Jun. de 2017
@Opt User: some questions:
- How did you get ~1000 variables into your workspace?
- Is there a good reason why these variables are not simply stored in one array? (After all, the name MATLAB comes from MATrix LABoratory, and not from "lets store our data in a thousand separate variables". Keeping data together as much as possible makes program design much simpler).
- What scheme do the variable names follow? Your examples show a, b, and c, but this limits the total to 26. What are the other 974 variables called?
- Where/how are these conditions defined? Is it possible to change their format/style/syntax?
Opt User
el 11 de Jun. de 2017
Walter Roberson
el 11 de Jun. de 2017
Take element #314 of the logical vector. What variable name does it correspond to? Is there a list of variable names, or is it something that is calculated, similar to Excel column naming ?
Opt User
el 11 de Jun. de 2017
Walter Roberson
el 11 de Jun. de 2017
computation_function = matlabFunction(symbolic_expression_list, 'vars', {sym(CellArrayOfVariableNames)} );
result_for_this_vector = computation_function(this_vector_of_logical_values)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!