MATLAB: How to create an array of the form [1,2,4,7,11,16] without the use of a loop array Is is possible to create a Matlab array where the jump between two consecutive numbers is not constant but increases by 1 every time? Best Answer It is, using the cumsum function (and a bit of fudging to get the result you want):x = 1:5;xs = [1 1+cumsum(x)] xs = 1 2 4 7 11 16 Related SolutionsMATLAB: Generate y(n)=y(n-1)+x(n) n=10y0=0; % Initial conditions y(1)=y0+x(1); for k=2:n y(k)=y(k-1)+x(k)end MATLAB: Multidimensional Arrays Global stiff matrix Substitute this portion of your code:LSM = zeros(2, 2, Num_elements);for x=1: Num_elementsLSM(1,1)= K;LSM(1,2)= -K;LSM(2,1)= -K;LSM(2,2)= K;endWith this one:LSM(1,1)= K;LSM(1,2)= -K;LSM(2,1)= -K;LSM(2,2)= K; Related QuestionHow to create a vector with for loopVectorisation of a loopHow to implement the followingNeed help with this Matlab script question? For loop!!How to shift specific elements in a array to a specific position
Best Answer