Tag Archive for 'Matlab'

Internetpret voor 2007-12-12

Matlab Distributed Computing

Vanmiddag een zalig stukje code geschreven:

% Create a scheduler
sched = findResource('scheduler', 'type', 'generic');
set(sched,'Configuration','PBS')
% specify the walltime
set (sched, 'SubmitFcn', {@pbsSubmitFcn, '00:30:00'})
% Create a Job
j=createJob(sched);
% Create Tasks
for ii=1:5000
createTask(j, @function, 1, {ii,ii});
end
% Submit the jobs
submit(j)
% Wait for PBS-jobs to finish
j.waitForState
% Get the results
res = j.getAllOutputArguments

Niet de code zelf is geniaal, maar wat het doet. Parallel 5000 functies laten lopen op evenveel processors (of minder als er minder processors vrij zijn). We hebben hier al een tijd een computer cluster op de KULeuven en die is zoooo handig. :-)

Technorati Tags: , ,

Matlab: array of true’s

Ok, now that I know the solution, this sounds really silly. I needed to create an array (of length N) with all entries set to logical true. A quick look in the help files suggested me to use the command ones (produces an array of 1’s) and to specify the class: array = ones(1,N,’logical’). However, Matlab refused to execute that. Looking again in the help, I found the true command which does exactly what I need: creating an array full of true’s. Simple, ain’t it? ;-)

array = true(1,N)

Matlab R2006a

matlabr2006a

Oh jawel! Gestuurd van hogerhand, nedergedaald in mijn nederig bureau’tje, stevig genesteld in de registries van mijn pentium, pronkend op mijn desktop: de nieuwste Matlab release, R2006a! De opvolger van release 14 service pack 3 is het rekenbeest der matrixrekenaars, bezit het toegankelijkste programmeer taaltje en bijhorend editor’tje en verlegd de grensen van imageprocessing. Fijne tijden liggen in het verschiet!