Effacer les filtres
Effacer les filtres

Creating more than one matrix from 1 matrix

1 vue (au cours des 30 derniers jours)
RUDRAKSH
RUDRAKSH le 31 Mai 2016
Modifié(e) : Andrei Bobrov le 31 Mai 2016
I have a matrix of order nx2 (n is more than 3000)
I want to brake this matrix into multiple matrix of order 300x2 as well as name them eg: matrix1 = (1:299)x2 matrix2 = (300:500)x2 . . . matrix10 = (2700:2999)x2 and so on
can anyone know how to do this through script.

Réponses (3)

Walter Roberson
Walter Roberson le 31 Mai 2016
You are much better off using mat2cell() to create a single cell array
mat2cell(YourMatrix, 300 * ones(1,10), 2)

KSSV
KSSV le 31 Mai 2016
You may also consider converting it into a 3D matrix
iwant = reshape(yourmatrix,[300,2,3000/(300)]);
You can access the matrix by iwant(:,:,i) i = 1,2,...10

Andrei Bobrov
Andrei Bobrov le 31 Mai 2016
Modifié(e) : Andrei Bobrov le 31 Mai 2016
[m,n] = size(yourmatrix);
% k - number rows in new array(s)
% if rem(m,k) ~= 0
out1 = mat2cell(A,accumarray(ceil((1:m)/k)',1),n);
out2 = permute(reshape([A; nan(mod(-m,k),n)].',n,k,[]),[2 1 3]);

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by