How can I run two code blocks in parallel?
Ältere Kommentare anzeigen
I have a few lines of code that I need to run at 200hz (publishing data). I have other code that currently only runs at <100hz, and I doubt I can optimise it far enough to run at 200hz. The data published in the first block of code is generated by the second, but so long as it is publishing at 200hz it won't matter if it is only actually sending new data on every second publish.
I tried parfor, but this doesn't seem like the right solution - as far as I can gather, it runs iterations of the same parfor loop in parallel, whereas I want to run two different blocks of code in parallel (publishing and calculating).
I have access to all toolboxes (academic licence).
Appreciate any help :)
1 Kommentar
Brendan
am 24 Sep. 2013
Antworten (2)
Ken Atwell
am 24 Sep. 2013
0 Stimmen
Edric Ellis
am 24 Sep. 2013
An alternative to BATCH might be SPMD. You could do something like this:
spmd(2)
if labindex == 1
% do first thing
else
% do the other thing
end
end
Inside an SPMD block you can also use the labSend family of functions to exchange data if necessary.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!