How to run two parallel loops which share variables?

조회 수: 4 (최근 30일)
ROSHITH SEBASTIAN
ROSHITH SEBASTIAN 2020년 3월 23일
댓글: ROSHITH SEBASTIAN 2020년 3월 27일
I have to run two loops in parallel which updates an array. The loops share the array and update the values which should be available for both loops.
Pseudo code:
loop 1 : while (true)
update(add) array A
check exit condition
break
end
loop 2: while (true)
update(edit, delete) array A
check exit condition
break
end
Both the loops should run in parallel and the number of iterations of each loop depends of random variables. But the changes made in loop1 should be visible in the next iteration of loop 2 and vice versa.
Can anyone please help me with this.

채택된 답변

Aditya Patil
Aditya Patil 2020년 3월 26일
Explicit multiprocessing is not supported in MATLAB. Instead, you can combine the for loops into a single for loop so that the output of one is available to another.
  댓글 수: 1
ROSHITH SEBASTIAN
ROSHITH SEBASTIAN 2020년 3월 27일
At present, I am using a similar approach with a single for loop to have specific checks at diffferent points to execute a block of statements. But, I am wondering if there is a better option to tackle the situation.
Thank you for letting me know that Matlab does not support multiprocessing.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by