MATLAB: Matrix[1,1,1,1;-1,-1,-1,-1;1,1,1,1] to vector[1,1,1,1,-1,-1,-1,-1,1,1,1,1] matrix to vector Matrix[1,1,1,1;-1,-1,-1,-1;1,1,1,1] to vector[1,1,1,1,-1,-1,-1,-1,1,1,1,1] How can I code? Best Answer I believe you intended semicolons (;) instead of colons (:) in your matrix definition.To convert it to a vector, use the reshape function:Matrix = [1,1,1,1; -1,-1,-1,-1; 1,1,1,1];Vector = reshape(Matrix', 1, [])Vector = 1 1 1 1 -1 -1 -1 -1 1 1 1 1EDIT — Added output of ‘Vector’. Related SolutionsMATLAB: -1 and 1 matrix Method One:>> N = 5;>> 2*mod(ndgrid(1:N,1:N),2)-1ans = 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1Method Two:>> 2*(ones(N,1)*mod(1:N,2)).'-1ans = 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1Method Three:>> repmat(2*mod(1:N,2).'-1,1,N)ans = 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 MATLAB: How to convert a 64 bit, two’s complement value(binary vector)[ 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] into a signed integer swapbytes(typecast(uint8(bin2dec(char(reshape(fliplr(A),8,[]).' + '0'))),'int64')) Related QuestionHow to determine the mean value every 10 data points and then calculate the standard deviation of the mean values (150)Create a array of 1 and -1
Best Answer