i am working with huge data (1800000x39 mtrix) in MATLAB. I have to extract a block of matrix from certain interval out of the this large matrix. How can i concatenate the matrix from each iteration.
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
data=('test.txt'); M=importdata(data);
for i=1:100 m1=M(i:i+3,1:3) end How can i concatenate the matrix generated by each iteration? Thank you in advance for your help.
2 comentarios
Stephen23
el 13 de Nov. de 2015
Concatenating arrays within loops is a very poor scripting concept in MATLAB. It leads to very slow code due to the repetitive memory allocations required. You can avoid this by preallocating the arrays, or even better learning to write vectorized code. For an explanation of array preallocation:
Mukunda Tamang
el 13 de Nov. de 2015
Respuestas (1)
Thorsten
el 13 de Nov. de 2015
First generate an index of all the rows you need, an then use this index to get the small matrix m:
idx = cell2mat(arrayfun(@(i) ([i:i+3]), 1:100, 'UniformOutput', false));
m = M(idx, 1:3);
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!