필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Loop inside while iterator block - slow calculation

조회 수: 1 (최근 30일)
mettala
mettala 2016년 3월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
I have somewhat large Simulink model which takes forever to run. I have located the problem inside a While iterator subsystem which is presented below:
In1 is a 1x1000 array and In3 is integer with value of 1000, ie the size of the array. Extract-function takes the n:th of this array and inserts it into the red circle where new array is generated based on the initial array and gained n:th value. The idea is to replace each value in the array with new, calculated value. In this example the value is only multiplied with 10, but in real model the calculation is more complex. The black circle generates values n=1,2,3...1000 which is used to select corresponding value in array. The blue circle makes sure that the While iterator subsystem is run until n=1000.
Used extract-function:
function i = extract(A,n)
i = A(n);
Used insert-function:
function A_out = insert(A_in,i,n)
A_in(n) = i;
A_out = A_in;
The outcome is what I want but it takes long time to compute. This example takes almost 5min to run (i7-5500U & 16GB). And this with 1x1000 array and 1 step. The real model would have up to 1500 time steps and a 1x9000 array changing each time.
I think that the loop (colored yellow) is the one to blame, but just can't come up with a solution to eliminate it. Is there some pre-made block or something that I can use to replace the red circle?

답변 (0개)

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by