MATLAB: Vector of n elements MATLAB and Simulink Student Suitevector Hey! How can I create such a vector: [1,1+2,1+2+3, ... ,1+2+3+...+n] without a loop? Best Answer Try this: v = 1:n;vs = cumsum(v). Related SolutionsMATLAB: Repeat an element in a vector [n(1) n]or[repmat(n(1),1) n] MATLAB: Matlab vector plus it self The cumsum function does exactly what you want:V=[2,6,3,9,0,-10];Vr = cumsum(V)Vr = 2 8 11 20 20 10 Related QuestionCan I create a vector with a specific pattern in MatlabHow to build this vectorHow to output a vector instead of a scalarFast and beautiful way to convert vector ranges to indexesRemoving elements in an array
Best Answer