Vectorizing nested for loop

조회 수: 6 (최근 30일)
Daniil
Daniil 2022년 12월 9일
댓글: Jan 2022년 12월 9일
Hello everyone. Im kinda new to matlab, please help to vectorize this
for ii = 1:100
for jj = 1:100
func1(ii, jj);
func2(ii, jj);
end
end
func1 using data, generated by func2 on each step, so i cannot tear execution apart. Problem is speed, i need as much as i can, but profiler says tht my loop is taking most of time, so i've read vectorization part of help, tried meshgrid option, but it kinda not what i am looking for. General idea would be to like execute both functions, using pregenerated data as entry parameters (saving call order), that would look same as generated but for loop.
Thanks for your help!
  댓글 수: 2
Torsten
Torsten 2022년 12월 9일
func1 using data, generated by func2 on each step
That contradicts your code where both functions are independent of each other.
How are the two functions coupled ?
Jan
Jan 2022년 12월 9일
@Daniil: Of course the vectorization wil concern func1 and func2. So post the contents of these functions.

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

답변 (0개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by