Parfor Closed loop variable

조회 수: 1 (최근 30일)
Abhishek M
Abhishek M 2014년 2월 13일
편집: Abhishek M 2014년 2월 21일
Hi, Is it possible to have a closed loop model design which uses the initial value of inputs and later on the inputs are computed based on the output for further iterations, that is, the output is used again as the input for the next computation steps??
If yes, 1). Can it be implemented using parfor because my idea involves huge number of iterations consuming lot of time which I don't want to spend. 2). I tried using simin and simout for the input and output respectively. The model works in for loop but not in parfor:(. Can you suggest some other source and sink blocks for this implementation.
Thanks in Advance :)

채택된 답변

Matt J
Matt J 2014년 2월 13일
You can use the parfor to parallelize computation in individual iterations, possibly reducing time per iteration. However, you cannot parallelize across iterations. The iterations lack the parallel independence assumed by PARFOR.
  댓글 수: 11
Matt J
Matt J 2014년 2월 19일
As far as I can see, you aren't currently doing anything to save the results of the different outer loop iterations, j, even in your regular for-loop. If x is supposed to be the output, you could do, e.g.,
parfor j=1:5
...
X{j}=x;
end
Incidentally, the code you show is using the same input file 'WS_loop' for every outer iteration, j. Since the input is always the same, the results of all those iterations will be identical, meaning you're just doing unnecessary repeat work.
Abhishek M
Abhishek M 2014년 2월 20일
편집: Abhishek M 2014년 2월 21일
Yeah Matt, i know i am repeating the same thing again n again but as i said this is just a demo model. The actual implementation model involves random numbers and huge logical calculations whose output varies with each simulation for the same inputs.
Anyways, thanx a lot for your help and suggestions on this.

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

추가 답변 (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