MATLAB: Multiplying vector members without repeating combinationsmultiplyvector Hi I need to multiply values from one vector in all combinations. For example Lets say that vector A=[1 2 3 4]' I need to get these products 1*2 1*3 1*4 2*3 2*4 3*4 Thanks for help Best Answer >> A = 1:4;>> prod(nchoosek(A,2),2)ans = 2 3 4 6 8 12 Related SolutionsMATLAB: Repeating elements (vector) There are most likely much more efficient algorithms than this:>> N = 4;>> X = (1:N)'*ones(1,N);>> X(triu(true(N)))ans = 1 1 2 1 2 3 1 2 3 4You can use X as indices into your vector to select the values that you want. MATLAB: Symbolic Matrix members evaluation Why do you want to create variable names like A1_3, A2_3, etc., when you can directly index the matrix A. Creating a separate variable name for each element is not an efficient coding approach: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval. Also, MATLAB does not provide a good way of doing what you want to do. Related QuestionAcquiring related Matrix MembersRepeating Values List ProblemcAccess to class membersFind member of elementRepeating elements of a vector
Best Answer