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.
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 13 Nov. 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
am 13 Nov. 2015
Antworten (1)
Thorsten
am 13 Nov. 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);
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!