Ältere Kommentare anzeigen
Simple question: why does FOR exist at all if we have PARFOR (which performs better and faster)?
Akzeptierte Antwort
Weitere Antworten (2)
Honglei Chen
am 4 Jun. 2012
2 Stimmen
To use PARFOR, each iteration has to be independent to each other. This is not always possible. The following document may be useful.
2 Kommentare
Nuchto
am 4 Jun. 2012
Titus Edelhofer
am 4 Jun. 2012
No, it won't. Just try to enter
parfor i=2:5
x(i) = x(i-1) + x(i-2);
end
You will see (if you have the Parallel Computing Toolbox) that x and parfor go a red line indicating an error.
Thomas
am 4 Jun. 2012
1 Stimme
to use 'parfor' you need the parallel computing toolbox, which is not useful in basic matlab. The 'for' can be used in basic matlab without the need for the parallel processing toolbox. The parallel processing toolbox is an extra addon and costs money..
As regards to speed, it is only faster if your code can be parallelized :)
In the par for all loops need to be independent of each other.
2 Kommentare
Honglei Chen
am 4 Jun. 2012
This is not entirely true as parfor is available in MATLAB, it just doesn't provide any benefit if you don't have Parallel Computing Toolbox, see
http://www.mathworks.com/help/techdoc/ref/parfor.html
Thomas
am 4 Jun. 2012
that was what I meant, that you do get it in matlab but is of no use without the PCT.. sorry if it came through as otherwise....
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!