📄 createcombinations.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% File: createModels.m%% Description: Given the current marginal product model (MPM), this% function returns an array of MPMs created by all possible pairwise merges% of subsets of the given MPM.%% @param model is a cell array with the current subsets. For instance, if% the model is completely independent and it has four% variables, it is: %model = {[0], [1], [2], [3] };%% @param orderCombination is the order of the combination (e.g., combination of 2% elements)%% @return arrayModels is a cell array with all the new models, that is, an% array with all the possible greedy combinations of% models%% Author: Albert Orriols-Puig%% Date: November 2006%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function [arrayModels] = createCombinations(model, orderCombination)modelSize = size (model, 2);comb = nchoosek(1:modelSize, orderCombination);%fprintf (' > Number of combinations: %d\n', size(comb,1));for i=1:size(comb,1) % Clearing variables clear newModel; clear a; clear j; % Getting the ith combination (the ith merged subset) a = []; for j = 1:length( comb(i,:) ) a = [a model{comb (i,j)}]; end newModel{1} = unique(a); % Getting the other subsets apart from the merged one cellsNotMerged = setdiff (1:modelSize, comb(i,:) ); j=2; for cell=cellsNotMerged newModel{j} = model{cell}; j = j+1; end % Adding the new subset to the array of models arrayModels{i} = newModel;endreturn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -