MATLAB: Add n+1 element to a vector vector I have a vector of the format: x = [X1 X2 … Xn] I want to add an element to the end, X(n+1). How do I do that? ex: x = [ 1 4 2 8] newX = [ 1 4 2 8 9] Best Answer If your X is a row vector, using newX = [X, aNewElement];If your X is a column vector, using newX = [X; aNewElement]; Related SolutionsMATLAB: Add element to a given vector One way>> x = 1:6x = 1 2 3 4 5 6>> x(end+1)=17x = 1 2 3 4 5 6 17>> MATLAB: Resetting a Time vector to zero newx=x-x(1) Related QuestionWriting N+1 by N+1 Matrix in MATLABAdd an integer x to certain values of a vectorNeed help; Fixing error and plotting functionsHow to improve a for
Best Answer