Can i use quadruple for loop?

조회 수: 2 (최근 30일)
Giannakis Stoukas
Giannakis Stoukas 2015년 4월 29일
댓글: Image Analyst 2015년 4월 29일
I need to make a swap between two variables of different row of a matrix and i think to use quadruple for to do it.Is it ok,or it will slow down a lot my programme?
  댓글 수: 1
Joseph Cheng
Joseph Cheng 2015년 4월 29일
It probably would not slow down the programme as the number of iterations would be the same. however can you dumb your implementation down to a simple example. Perhaps the collective minds here can come up with an easier way.

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

답변 (1개)

Image Analyst
Image Analyst 2015년 4월 29일
How many iterations in each for loop? Unless you're doing tens or hundreds of millions of iterations in the innermost part, you probably won't notice any slowdown. Whether it can be vectorized really depends on what "swap between two variables of different row of a matrix". I have no idea what that means. Maybe you can illustrate with a small 4 by 5 matrix.
  댓글 수: 2
Giannakis Stoukas
Giannakis Stoukas 2015년 4월 29일
Well the nu code will be for i=1:10
for j=1:14
for k=1:10
for l=1:14
if A(i,j)>A(k,l) { continues the programme }
Image Analyst
Image Analyst 2015년 4월 29일
19,600 iterations will happen faster than the blink of an eye. Don't worry about it.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by