parallel processing in MATLAB

4 views (last 30 days)
Alina
Alina on 14 Mar 2014
Commented: Alina on 14 Mar 2014
can we perform parallel processing in MATLAB...
Like i have a code that take input and gives out output.
e.g, the code take single number as input and convert it into its square. Input = 2 4 6 8 10
the code take 2 as a input and gives 4 as a output mean while the code take 4 as a input and gives 16 as a output and so on.. but in parallel that as when code take 2 in put at the same time it take 4 , 6 8 and 10 as an input to produce there squares as a output at the same time...?
  2 Comments
Benjamin Avants
Benjamin Avants on 14 Mar 2014
Could you clarify what exactly you mean by "the same time"? If you mean as one function call, you can pass a vector of inputs, operate on the whole vector, and output the resulting vector. If you mean actually being computed at the same time, it is possible on multi-core processors or cluster type configurations as long as you have the parallel computing toolbox. Of course, you can only do as many computations simultaneously as you have processors(cores) available.
Newer versions of MATLAB have some inherent multi-core functionality when doing vector and matrix operations but I don't know the details.
If you mean that you want to be able to continue calling the function with new inputs before it returns from the previous call, you can create and run timers that execute your function, but that would not be a good way to do it with large functions or a large number of inputs because the timer threads would be competing with one another for processor time and memory.
Alina
Alina on 14 Mar 2014
yes i want to continue calling the function with new inputs before it returns from the previous call, or want to get outputs at the same instant

Sign in to comment.

Answers (1)

Matt J
Matt J on 14 Mar 2014
Edited: Matt J on 14 Mar 2014
MATLAB internally parallelizes matrix operations like
Output=Input.^2
where I've assumed the Input is a vector,
Input=[2 4 6 ...]
You can do more complicated parallel processing with the Parallel Computing Toolbox, if you have it.

Categories

Find more on Parallel Computing in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!