getting rid of a loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have a cell array X which has around 1 million rows. each row has a 1x18 cell in it. I want to select columns 4,5,10,18 from each row. To do so I am running a loop v = regexp( X, ',', 'split'); ncol=[4 5 10 18];%numeric columns v2=nan(length(v),length(ncol));% numeric variables empty matrix
for j=1:length(v)
v0=[v{j,1}];
v2(j,1:length(ncol))=str2double(v0(1,ncol));
end
end
is it possible to avoid the loop and select columns 4,5,10,18 of each row of X?
1 Kommentar
Image Analyst
am 26 Jul. 2012
Edit your question. Highlight the code part of the question. Click the "{} Code" box above to format it so that it looks like a regular program.
Antworten (2)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!