How I can split a matrix in four matrixes
Mostra commenti meno recenti
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.
3 Commenti
Maryam Hamrahi
il 28 Giu 2016
Stephen23
il 28 Giu 2016
So if the number of rows n is unknown, how many rows are in each of the four matrices ?
Have you tried using indexing, or mat2cell ?
Maryam Hamrahi
il 28 Giu 2016
Risposta accettata
Più risposte (1)
David Sanchez
il 28 Giu 2016
M = rand(1001,3); % your matrix
L = size(M,1); % L = number of rows
n = floor(L/4); % number of rows for your matrices
N = cell(4,1);
for k=1:3
N{k,1} = M( ((k-1)*n+1):n*k,: );
end
N{4,1} = M((3*n+1):L,:);
% to access your matrices...
N_1 = cell2mat(N(1,1));
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!