MATLAB: How to split a matrix in four matrixes how i can split a matrix I have a nx3 matrix and I would like to split it in four matrices with different number of rows and three columns. any help is appreciated. Best Answer clc; clear all ;A = rand(100,3) ; % rows should be greater then 4 a = size(A,1); % rows in An = 4; % number of partitions out = diff([0,sort(randperm(a-1,n-1)),a]); % split rows into four random parts % else you enter your own four numbers such that sum is size(A,1)% four matricesA1 = A(1:out(1),:) ;A2 = A(out(1)+1:out(1)+out(2),:) ;A3 = A(out(2)+1:out(2)+out(3),:) ;A4 = A(out(3)+1:out(3)+out(4),:) ; Related SolutionsMATLAB: I want to calculate the equation: I = [5 6 7 8 ; 2 8 6 3 ; 4 0 4 2 ; 5 0 1 0]; [l, ~, iI] = unique(I); nk = accumarray(iI, 1); XT = l'*nk/numel(I) MATLAB: Fastest way to divide a matrix columns into two matrices %If A is your matrixA=randi(10,5,8) % examplec5=A(:,5) % the fifth columnB=A(:,[1:4 6:m]) % remaining matrix Related QuestionMaintain shape of logical index maskHow to split 14400×1 into 20 719×1 matricesVectorizationWhat’s the best way to build a block sparse matrix whose entries are diagonal matrices
Best Answer