q((2:n-1),(2:n-1)) = a*u((3:n),(2:n-1));
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!