How the concatenate every combination of vectors?
1 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I have 6 vectors and i want to concatenate every combination between these vectors in one individual vector. Let's call the six vectors a,b,c,d,e,f.What I want to do is create a several concatenated vector like this:
first_vector=[a]; second_vector=[b]; (...); n_vector=[a b]; (...); last=[a b c d e f];
Can somebody help me? Joaquim
0 个评论
采纳的回答
Guillaume
2017-5-2
allvectors = {a, b, c, d, e, f}; %cell array of all the vectors
allcombs = {};
for c = 1:numel(allvectors)
combidx = nchoosek(1:numel(allvectors), c);
ccombs = cell(size(combidx, 1), 1);
for row = 1:numel(ccombs)
ccombs{row} = [allvectors{combidx(row, :)}];
end
allcombs = [allcombs; ccombs];
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!