[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: running blocks of code in parallel?
From: |
Bill Denney |
Subject: |
Re: running blocks of code in parallel? |
Date: |
Tue, 09 Dec 2008 20:58:33 -0500 |
User-agent: |
Thunderbird 2.0.0.18 (Windows/20081105) |
Jared wrote:
> I have the following code that I need to run on several matrices. Is
> there a way to run the code in some kind of parallel fashion so that I
> don't need to wait for one block to finish before the other starts?
> for i=1:length(DJI)
> DJI2(i,1)=datenum(char(DJI(i,2)),'yyyy-mm-dd');
> DJI2(:,2:6) = reshape(str2num(strvcat(DJI(:,3:7)(:)), length(DJI(:,3:7))));
> end
Hi Jared,
FYI, when I sent the suggestion earlier, I meant
for i=1:length(DJI)
DJI2(i,1)=datenum(char(DJI(i,2)),'yyyy-mm-dd');
end
DJI2(:,2:6) = reshape(str2num(strvcat(DJI(:,3:7)(:)), length(DJI(:,3:7))));
And now that I've had a chance to take a couple minutes off of my day
job, the better way to do this would be:
tmp = strvcat(DIJ(:,2));
y = str2num(tmp(:,1:4));
m = str2num(tmp(:,6:7));
d = str2num(tmp(:,9:10))
DJI2(i,1)=datenum(y, m, d);
DJI2(:,2:6) = reshape(str2num(strvcat(DJI(:,3:7)(:)), length(DJI(:,3:7))));
That should be much faster than the loop and than having datenum do the
string processing.
Have a good day,
Bill