Creating a matrix from a lagrer matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Benedict Egbon
el 7 de Mzo. de 2019
Comentada: Benedict Egbon
el 7 de Mzo. de 2019
Hello everyone.
Please I need help in automatically dividing the matrix A below into three 5by 1 matrix.
A=[1
2
3
4
5
6
8
9
10
11
12
13
14
15]
Such that the first matrix created will be say
B=[1
2
3
4
5]
Thanks.
0 comentarios
Respuesta aceptada
Akira Agata
el 7 de Mzo. de 2019
How about the following?
In this case, C{1}, C{2}, ..., C{151} are 200-by-1 matrices each, extracted from original 30194-by-1 matrix.
% Sample 30194-by-1 data
A = rand(30194,1);
% Padding with "nan"
n = 200;
N = numel(A);
A = [A;nan(ceil(N/n)*n-N,1)];
% Divide A into 200-by-1 segments
C = mat2cell(A,repelem(n,ceil(N/n)));
2 comentarios
Más respuestas (1)
Kevin Phung
el 7 de Mzo. de 2019
A = reshape(1:15,5,3); %reshaped into a 5x3 matrix.
B =A(:,1); %one of the column vectors that you desire
reading up on indexing can help:
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!