Vectorizing a simple for loop
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi everyone, I have a simple question that I somehow can't seem to figure out
so i know for this type of loop for example:
for i = 2:n-1
for j = 2:n-1
q(i,j) = a*u(i,j)
end
end
can be simply expressed as: q((2:n-1),(2:n-1)) = a*u((2:n-1),(2:n-1));
what if my expression was as follow: for i = 2:n-1 for j = 2:n-1 q(i,j) = a*u(i+1,j) end end
how could I incorporate the "i+1" expression into vectorizing.
Thank you for your help
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!