필터 지우기
필터 지우기

Generate all probability of non repeated combinations of .mat files

조회 수: 1 (최근 30일)
M
M 2022년 3월 2일
편집: M 2022년 3월 2일
How can I generate all probability of non repeated combinations of .mat files.
For exapmle there are the following mat files : One.mat , Two.mat , Three.mat
and each of these files contains 2 vector for example: One.mat contains V1 and V2 vectors, Two.mat: contains C1 and C2 vectors , Three.mat: contains D1 and D2 vectors.
So I want to generate the following combinations:
Comb1.mat contains: One.mat and Two.mat
Comb2.mat contains: One.mat and Two.mat
Comb3.mat contains: Two.mat and Three.mat
Comb4.mat contains: One.mat ,Two.mat and Three.mat
Is there any code can help me to achieve this?

채택된 답변

Matt J
Matt J 2022년 3월 2일
편집: Matt J 2022년 3월 2일
names=["One","Two","Three"];
N=numel(names);
combs=cell(N,1);
for i=1:N
combs{i}=num2cell(nchoosek(1:numel(names),i),2);
end
combs=vertcat(combs{:});
N=size(combs,1);
for i=1:N
S=arrayfun(@load, names(combs{i}) ,'uni',0);
args=cellfun(@namedargs2cell, S,'uni',0) ;
args=[args{:}];
S=struct(args{:});
save("Comb"+i,'-struct','S')
end
  댓글 수: 5
M
M 2022년 3월 2일
편집: M 2022년 3월 2일
@Matt J thank you, the error is solved but this code gave just 2 combinations . Can you please edit the code so it can gave all possibility of combinations.
This combination is missed : Comb4.mat contains: One.mat ,Two.mat and Three.mat
M
M 2022년 3월 2일
편집: M 2022년 3월 2일
@Matt JThank you so much! The code is working now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Parallel Server에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by