Generate all possible patterns from an existent table
Show older comments
Hello comunity,
ted learning matlab and I need your help to create a code that return all patterns using the data from a table. The dataset that I got from my test are like the following:
T =
[ 2 5 10 17 33
1 10 19 20 28
7 23 28 29 32
11 19 22 34 36
4 7 27 36 39
1 17 21 24 31
10 11 14 24 25]
The patterns should be based on variables of 5 numbers. Ex: P1= [1 2 3 4 5], P2 = [6 7 8 9 10] until 40. Applying it to the data from the table and using matlab the output to be something like:
P1, P1, P2, P4, P7
P1, P2, P4, P4, P6
P2, P5, P6, P6, P7
...
At the end, I should get another with a result of how many times each pattern occured. I can do all this using microsoft excel, however, whenever I got new data I have to do all over again because the new dataset maybe larger.
This how I was doing it:
%% Data extraction
Pick5 = readtable("Data_I.xlsx"); % Extract the excel file with all data
T = table2cell(Pick5) % convert the table to Cells
D1 = Pick5.Draw1; % Extract Column 1
D2 = Pick5.Draw2; % Extract Column 2
D3 = Pick5.Draw3; % Extract Column 3
D4 = Pick5.Draw4; % Extract Column 4
D5 = Pick5.Draw5; % Extract Column 5
Draw = [D1 D2 D3 D4 D5] %% Defining a new matrix using the previous (D's) Results
%% Pattern Generation (P-Pattern)
% Pat = sym('p', [1 8]); % create the pattern variables (ex: P1, P2 ...)
% pn = nchoosek([Pat],5); % create a symbolic matrix with the variables P1, P2 etc.
% Str = string(pn) % transfor the symbolic matrix to string
The thing is that this code works by first generaing all possible permutation which my cause me problem for situation where I have to run permutation of # over 11.
Thanks in advance
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!