Hi, I need to create a combination of multiplications of values of the vector without repetition. For example, I have vector inp = {['f1'] ['f2'] ['f3'] ['f4']},(where f1-4 is a predetermined value), the output should look like this: f1, f2, f3, f4, f1*f2, f1*f3, f1*f4, f2*f3, f2*f4, …. f1*f2*f3*f4. But it should not be displayed in this form, and as the result of the multiplication. I tried to implement it by taking the code from one of the topics on the forum, but it only creates arrays of these combinations. I can not understand how to modify this code to add the multiplication. p.s. Sorry for my English, I communicate through Yandex translator 🙂
if trueinp = {['f1'] ['f2'] ['f3'] ['f4']} out = cell(size(inp));for k = 1:numel(inp) out{k} = num2cell(nchoosek(1:numel(inp),k),2);endout = vertcat(out{:})';Pf = {};for k = 1:numel(out) inp(out{k}) b = horzcat(inp{out{k}}) Pf=[Pf [b]];endend
Best Answer