Filter löschen
Filter löschen

Want a matrix of n number of columns having every possible combinations of shorten elements in its row, an example is given below.

2 Ansichten (letzte 30 Tage)
N = 3;
phi_mn=[dec2bin(0:2^N-1)' - '0']';
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
I want to make the same matrix having elements 0,1/2,1,3/2 instead of 0 and 1 only. So the new matrix will have 4^3 rows instaed of 2^3.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Feb. 2022
Bearbeitet: Walter Roberson am 27 Feb. 2022
Note: the below, as coded, is only valid up to base 10.
base = 4
base = 4
digits = 3
digits = 3
phi_mn = dec2base(0:base^digits-1, base) - '0'
phi_mn = 64×3
0 0 0 0 0 1 0 0 2 0 0 3 0 1 0 0 1 1 0 1 2 0 1 3 0 2 0 0 2 1

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by