Sequence Generation of a table
1 次查看(过去 30 天)
显示 更早的评论
Hi, I am trying to made a code to generate a sequence like the one in picture but am not really good at Matlab code as much as C++ (using loops and iterations) but I cant use the same logic here. Would be thankful to you if you can help me with a code to generate output like the one in picture.
0 个评论
回答(1 个)
Bhaskar R
2020-1-5
First 4 columns follows truth table notation values and next two columns are one,
n = 4; % truth table size
header = {'PL100', 'CY103', 'CY104','CY105', 'CY107', 'CY108'}; % header of table
truth_table = fliplr(fullfact(ones(1, n) + 1)); % your truth table
truth_table(:, end+1:end+2) = 1; % append ones to next two columns
table_values = truth_table + repmat(10* [1:size(truth_table, 2)], 2^n,1); % construct values table
tb = strcat('seq', cellfun(@num2str,num2cell(table_values), 'UniformOutput', false)); % append char 'seq' by converting to char type
tb = [header; tb]; % append header
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!