From: radar on 3 May 2010 18:45 I have a 500,000 x 3 cellarray with the first col being a sql server datetime string Is there a better way than shown below to copy the cell array to a matrix of the same dimension while converting the first col values to datenums mat=zeros(size(ca)); for k = 1:length(ca) mat(k,1) = datenum(ca{k,1}) mat(k,2) = ca{k,2} mat(k,3) = ca{k,3} end;
From: Walter Roberson on 3 May 2010 23:15 radar wrote: > I have a 500,000 x 3 cellarray with the first col being a sql server datetime string > Is there a better way than shown below to copy the cell array to a matrix of the same dimension while converting the first col values to datenums > mat=zeros(size(ca)); > > for k = 1:length(ca) > mat(k,1) = datenum(ca{k,1}) > mat(k,2) = ca{k,2} > mat(k,3) = ca{k,3} > end; I would suggest trying the timing of this: mat(:,1) = datenum(ca(:,1)); mat(:,2) = cell2mat(ca(:,2)); mat(:,3) = cell2mat(ca(:,3));
From: radar on 4 May 2010 07:22 *Walter--Thanks--much faster*
|
Pages: 1 Prev: running code for 22 hours now... Next: How can I add string to an integer matrix ?? |