MATLAB: How can i create array of all -1 numbers in it arrays Item one Item two Best Answer X = repmat(-1, [3, 4]) Related SolutionsMATLAB: Flipping the numbers 1 to -1 Try using a while loop:a = ones(1,4)k=1;mag=[];while k<=numel(a) x = rand()>=0.5; a(k)=a(k)-2*x; mag(end+1)=sum(a); k=k+x;endProduces:a = -1 -1 -1 -1mag = 4 4 2 2 2 0 -2 -4 MATLAB: Sum Matrix excluding certain values y = sum(MatrixA(MatrixA > 3)) Related QuestionPlot +1 +1 -1 -1 rectangular pulseHow to randomly combine the elements of two arrays in MATLAB 7.5 (R2007b)Create a array of 1 and -1-1 and 1 matrix
Best Answer