MATLAB: Replace the elements of a matrix matrix array Hello everyone, I have an A matrix as A=[a b ; c d ; e f ; g h] and want to get B matrix as B=[a ; b; c; d; e; f; g; h] using A matrix. How can I code it? Thanks Best Answer One wayz = permute( A, [2,1] );B = z(:);or z = permute( A, [2,1] );B = reshape( z, [],1 ); Related SolutionsMATLAB: Reshape a matrix in different way Is this Cody? reshape( permute( cat( 2, 2*mmm-1, 2*mmm ), [2,1] ), [],1 )or with fewer characters reshape( permute( [2*mmm-1,2*mmm], [2,1] ), [],1 )or reshape( [2*mmm-1,2*mmm]', [],1 ) MATLAB: Read data from file Two variantsfid = fopen( 'cssm.txt' );cac = textscan( fid, '(%d,%d) (%d,%d)', 'Whitespace','' ... , 'Delimiter',' ', 'CollectOutput',true );fclose( fid );num1 = cac{1};fid = fopen( 'cssm.txt' );cac = textscan( fid, '%d%d%d%d', 'MultipleDelimsAsOne',true ... , 'Delimiter','(),', 'CollectOutput',true );fclose( fid );num2 = cac{1};m1 = permute( num2(:,1), [2,1] );m2 = permute( num2(:,2), [2,1] );m3 = permute( num2(:,3), [2,1] );m4 = permute( num2(:,4), [2,1] );Inspect the result>> all(all(num1==num2))ans = 1>> num2num2 = 2 4 5 6 34 26 22 78 18 76 33 50>>Do you really want m1,m2,m3 and m4? Related QuestionI want to create a MATLAB code for a matrix of m*n which have each element p*p matrix, plz help to solve thisCompare two arrays (intersection) and create new array with output columns, but with repetitionsProduct of three 1d vectors and a 3d arrayMove matrix rows and columns
Best Answer