Building a recursive string function.

I am trying to build a function whose output is a list of all possible boolean expressions with an upper bound. For three variables p,q and r my function would be, theoretically:
  1. f(0) = {p,q,r} // this notation refer to the mathematical set such that p,q and r belong to f(0).
  2. f(n+1) = { (A & B) such that A and B belongs to f(n) } Union { (A or B) such that A and B belongs to f(n) } Union { (not A) such that A belongs to f(n) }
I want to receive a matrix whose rows are the strings of all the possible strings corresponding to boolean formulas build by n iterations of the function. For example:
f(2)=['p' ; 'q' ; 'r' ; '(p&q)' ; 'p&(p or q)' ; 'r or (p & r)' ; ... ]

1 件のコメント

José-Luis
José-Luis 2016 年 9 月 16 日
What have you tried so far?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2016 年 9 月 16 日

コメント済み:

2016 年 9 月 16 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by